3
0

Simplify code for existing-user check in signup

This commit is contained in:
Denis Arh
2019-07-03 14:37:07 +02:00
parent 751f93894a
commit 4973638e2a
2 changed files with 21 additions and 20 deletions
+1
View File
@@ -175,6 +175,7 @@ func (r user) Find(filter types.UserFilter) (set types.UserSet, f types.UserFilt
}
func (r user) Total() (count uint) {
count, _ = r.count(r.query())
return
}
+20 -20
View File
@@ -278,28 +278,28 @@ func (svc auth) InternalSignUp(input *types.User, password string) (u *types.Use
existing, err := svc.users.FindByEmail(input.Email)
if err == nil && existing.Valid() {
if len(password) > 0 {
cc, err := svc.credentials.FindByKind(existing.ID, credentialsTypePassword)
if err != nil {
return nil, errors.Wrap(err, "could not find credentials")
}
err = svc.checkPassword(password, cc)
if err != nil {
return nil, errors.Wrap(err, "user with this email already exists")
}
if !existing.EmailConfirmed {
err = svc.sendEmailAddressConfirmationToken(existing)
if err != nil {
return nil, err
}
}
return existing, nil
if len(password) == 0 {
return nil, errors.New("invalid username/password combination")
}
return nil, errors.Wrap(err, "user with this email already exists")
cc, err := svc.credentials.FindByKind(existing.ID, credentialsTypePassword)
if err != nil {
return nil, errors.Wrap(err, "could not find credentials")
}
err = svc.checkPassword(password, cc)
if err != nil {
return nil, errors.Wrap(err, "user with this email already exists")
}
if !existing.EmailConfirmed {
err = svc.sendEmailAddressConfirmationToken(existing)
if err != nil {
return nil, err
}
}
return existing, nil
// if !svc.settings.internalSignUpSendEmailOnExisting {
// return nil,errors.Wrap(err, "user with this email already exists")