mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Better ask email verification flow
Allow user to resend the email verification link when changing the current email Fix success messages when validating a new email
This commit is contained in:
parent
e19ee1ebc9
commit
986e71a1f7
29 changed files with 426 additions and 271 deletions
|
@ -37,7 +37,8 @@ import {
|
|||
HasOne,
|
||||
Is,
|
||||
IsEmail,
|
||||
IsUUID, Scopes,
|
||||
IsUUID,
|
||||
Scopes,
|
||||
Table,
|
||||
UpdatedAt
|
||||
} from 'sequelize-typescript'
|
||||
|
@ -173,7 +174,7 @@ type WhereUserIdScopeOptions = { whereUserId?: '$userId' | '"UserModel"."id"' }
|
|||
daily: false,
|
||||
onlyMaxResolution: true
|
||||
}) +
|
||||
')'
|
||||
')'
|
||||
),
|
||||
'videoQuotaUsed'
|
||||
],
|
||||
|
@ -185,7 +186,7 @@ type WhereUserIdScopeOptions = { whereUserId?: '$userId' | '"UserModel"."id"' }
|
|||
daily: true,
|
||||
onlyMaxResolution: true
|
||||
}) +
|
||||
')'
|
||||
')'
|
||||
),
|
||||
'videoQuotaUsedDaily'
|
||||
]
|
||||
|
@ -205,7 +206,7 @@ type WhereUserIdScopeOptions = { whereUserId?: '$userId' | '"UserModel"."id"' }
|
|||
daily: false,
|
||||
onlyMaxResolution: false
|
||||
}) +
|
||||
')'
|
||||
')'
|
||||
),
|
||||
'totalVideoFileSize'
|
||||
]
|
||||
|
@ -225,7 +226,7 @@ type WhereUserIdScopeOptions = { whereUserId?: '$userId' | '"UserModel"."id"' }
|
|||
'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
|
||||
'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' +
|
||||
`WHERE "account"."userId" = ${options.whereUserId}` +
|
||||
')'
|
||||
')'
|
||||
),
|
||||
'videosCount'
|
||||
],
|
||||
|
@ -234,13 +235,13 @@ type WhereUserIdScopeOptions = { whereUserId?: '$userId' | '"UserModel"."id"' }
|
|||
'(' +
|
||||
`SELECT concat_ws(':', "abuses", "acceptedAbuses") ` +
|
||||
'FROM (' +
|
||||
'SELECT COUNT("abuse"."id") AS "abuses", ' +
|
||||
`COUNT("abuse"."id") FILTER (WHERE "abuse"."state" = ${AbuseState.ACCEPTED}) AS "acceptedAbuses" ` +
|
||||
'FROM "abuse" ' +
|
||||
'INNER JOIN "account" ON "account"."id" = "abuse"."flaggedAccountId" ' +
|
||||
`WHERE "account"."userId" = ${options.whereUserId}` +
|
||||
'SELECT COUNT("abuse"."id") AS "abuses", ' +
|
||||
`COUNT("abuse"."id") FILTER (WHERE "abuse"."state" = ${AbuseState.ACCEPTED}) AS "acceptedAbuses" ` +
|
||||
'FROM "abuse" ' +
|
||||
'INNER JOIN "account" ON "account"."id" = "abuse"."flaggedAccountId" ' +
|
||||
`WHERE "account"."userId" = ${options.whereUserId}` +
|
||||
') t' +
|
||||
')'
|
||||
')'
|
||||
),
|
||||
'abusesCount'
|
||||
],
|
||||
|
@ -251,7 +252,7 @@ type WhereUserIdScopeOptions = { whereUserId?: '$userId' | '"UserModel"."id"' }
|
|||
'FROM "abuse" ' +
|
||||
'INNER JOIN "account" ON "account"."id" = "abuse"."reporterAccountId" ' +
|
||||
`WHERE "account"."userId" = ${options.whereUserId}` +
|
||||
')'
|
||||
')'
|
||||
),
|
||||
'abusesCreatedCount'
|
||||
],
|
||||
|
@ -262,7 +263,7 @@ type WhereUserIdScopeOptions = { whereUserId?: '$userId' | '"UserModel"."id"' }
|
|||
'FROM "videoComment" ' +
|
||||
'INNER JOIN "account" ON "account"."id" = "videoComment"."accountId" ' +
|
||||
`WHERE "account"."userId" = ${options.whereUserId}` +
|
||||
')'
|
||||
')'
|
||||
),
|
||||
'videoCommentsCount'
|
||||
]
|
||||
|
@ -285,7 +286,6 @@ type WhereUserIdScopeOptions = { whereUserId?: '$userId' | '"UserModel"."id"' }
|
|||
]
|
||||
})
|
||||
export class UserModel extends SequelizeModel<UserModel> {
|
||||
|
||||
@AllowNull(true)
|
||||
@Is('UserPassword', value => throwIfNotValid(value, isUserPasswordValid, 'user password', true))
|
||||
@Column
|
||||
|
@ -554,8 +554,8 @@ export class UserModel extends SequelizeModel<UserModel> {
|
|||
|
||||
static listWithRight (right: UserRightType): Promise<MUserDefault[]> {
|
||||
const roles = Object.keys(USER_ROLE_LABELS)
|
||||
.map(k => parseInt(k, 10) as UserRoleType)
|
||||
.filter(role => hasUserRight(role, right))
|
||||
.map(k => parseInt(k, 10) as UserRoleType)
|
||||
.filter(role => hasUserRight(role, right))
|
||||
|
||||
const query = {
|
||||
where: {
|
||||
|
@ -675,6 +675,18 @@ export class UserModel extends SequelizeModel<UserModel> {
|
|||
return UserModel.findAll(query)
|
||||
}
|
||||
|
||||
static loadByPendingEmailCaseInsensitive (pendingEmail: string): Promise<MUserDefault[]> {
|
||||
const query = {
|
||||
where: where(
|
||||
fn('LOWER', col('pendingEmail')),
|
||||
'=',
|
||||
pendingEmail.toLowerCase()
|
||||
)
|
||||
}
|
||||
|
||||
return UserModel.findAll(query)
|
||||
}
|
||||
|
||||
static loadByUsernameOrEmailCaseInsensitive (usernameOrEmail: string): Promise<MUserDefault[]> {
|
||||
const query = {
|
||||
where: {
|
||||
|
@ -863,8 +875,8 @@ export class UserModel extends SequelizeModel<UserModel> {
|
|||
|
||||
return 'SELECT COALESCE(SUM("size"), 0) AS "total" ' +
|
||||
'FROM (' +
|
||||
`SELECT ${sizeSelect} AS "size" FROM (${webVideoFiles} UNION ${hlsFiles}) t1 ` +
|
||||
'GROUP BY "t1"."videoId"' +
|
||||
`SELECT ${sizeSelect} AS "size" FROM (${webVideoFiles} UNION ${hlsFiles}) t1 ` +
|
||||
'GROUP BY "t1"."videoId"' +
|
||||
') t2'
|
||||
}
|
||||
|
||||
|
@ -925,7 +937,7 @@ export class UserModel extends SequelizeModel<UserModel> {
|
|||
}
|
||||
|
||||
return UserModel.findAll(query)
|
||||
.then(u => u.map(u => u.username))
|
||||
.then(u => u.map(u => u.username))
|
||||
}
|
||||
|
||||
hasRight (right: UserRightType) {
|
||||
|
@ -1037,13 +1049,13 @@ export class UserModel extends SequelizeModel<UserModel> {
|
|||
|
||||
if (Array.isArray(this.Account.VideoChannels) === true) {
|
||||
json.videoChannels = this.Account.VideoChannels
|
||||
.map(c => c.toFormattedJSON())
|
||||
.sort((v1, v2) => {
|
||||
if (v1.createdAt < v2.createdAt) return -1
|
||||
if (v1.createdAt === v2.createdAt) return 0
|
||||
.map(c => c.toFormattedJSON())
|
||||
.sort((v1, v2) => {
|
||||
if (v1.createdAt < v2.createdAt) return -1
|
||||
if (v1.createdAt === v2.createdAt) return 0
|
||||
|
||||
return 1
|
||||
})
|
||||
return 1
|
||||
})
|
||||
}
|
||||
|
||||
return json
|
||||
|
@ -1053,7 +1065,7 @@ export class UserModel extends SequelizeModel<UserModel> {
|
|||
const formatted = this.toFormattedJSON({ withAdminFlags: true })
|
||||
|
||||
const specialPlaylists = this.Account.VideoPlaylists
|
||||
.map(p => ({ id: p.id, name: p.name, type: p.type }))
|
||||
.map(p => ({ id: p.id, name: p.name, type: p.type }))
|
||||
|
||||
return Object.assign(formatted, { specialPlaylists })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue