коммит произвёл
GitHub
родитель
2de65cfb11
Коммит
869da7a78b
@@ -308,6 +308,48 @@ func (us SqlUserStore) UpdateAuthData(userId string, service string, authData *s
|
||||
return userId, nil
|
||||
}
|
||||
|
||||
// ResetAuthDataToEmailForUsers resets the AuthData of users whose AuthService
|
||||
// is |service| to their Email. If userIDs is non-empty, only the users whose
|
||||
// IDs are in userIDs will be affected. If dryRun is true, only the number
|
||||
// of users who *would* be affected is returned; otherwise, the number of
|
||||
// users who actually were affected is returned.
|
||||
func (us SqlUserStore) ResetAuthDataToEmailForUsers(service string, userIDs []string, includeDeleted bool, dryRun bool) (int, error) {
|
||||
whereEquals := sq.Eq{"AuthService": service}
|
||||
if len(userIDs) > 0 {
|
||||
whereEquals["Id"] = userIDs
|
||||
}
|
||||
if !includeDeleted {
|
||||
whereEquals["DeleteAt"] = 0
|
||||
}
|
||||
|
||||
if dryRun {
|
||||
builder := us.getQueryBuilder().
|
||||
Select("COUNT(*)").
|
||||
From("Users").
|
||||
Where(whereEquals)
|
||||
query, args, err := builder.ToSql()
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "select_count_users_tosql")
|
||||
}
|
||||
numAffected, err := us.GetReplica().SelectInt(query, args...)
|
||||
return int(numAffected), err
|
||||
}
|
||||
builder := us.getQueryBuilder().
|
||||
Update("Users").
|
||||
Set("AuthData", sq.Expr("Email")).
|
||||
Where(whereEquals)
|
||||
query, args, err := builder.ToSql()
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "update_users_tosql")
|
||||
}
|
||||
result, err := us.GetMaster().Exec(query, args...)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "failed to update users' AuthData")
|
||||
}
|
||||
numAffected, err := result.RowsAffected()
|
||||
return int(numAffected), err
|
||||
}
|
||||
|
||||
func (us SqlUserStore) UpdateMfaSecret(userId, secret string) error {
|
||||
updateAt := model.GetMillis()
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user