diff options
Diffstat (limited to 'models/user_email.go')
-rw-r--r-- | models/user_email.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/models/user_email.go b/models/user_email.go index 8c5fbf6d6a..528ebb0540 100644 --- a/models/user_email.go +++ b/models/user_email.go @@ -31,18 +31,18 @@ func ActivateEmail(email *user_model.EmailAddress) error { } func updateActivation(e db.Engine, email *user_model.EmailAddress, activate bool) error { - user, err := getUserByID(e, email.UID) + user, err := user_model.GetUserByIDEngine(e, email.UID) if err != nil { return err } - if user.Rands, err = GetUserSalt(); err != nil { + if user.Rands, err = user_model.GetUserSalt(); err != nil { return err } email.IsActivated = activate if _, err := e.ID(email.ID).Cols("is_activated").Update(email); err != nil { return err } - return updateUserCols(e, user, "rands") + return user_model.UpdateUserColsEngine(e, user, "rands") } // MakeEmailPrimary sets primary email address of given user. @@ -58,12 +58,16 @@ func MakeEmailPrimary(email *user_model.EmailAddress) error { return user_model.ErrEmailNotActivated } - user := &User{} + user := &user_model.User{} has, err = db.GetEngine(db.DefaultContext).ID(email.UID).Get(user) if err != nil { return err } else if !has { - return ErrUserNotExist{email.UID, "", 0} + return user_model.ErrUserNotExist{ + UID: email.UID, + Name: "", + KeyID: 0, + } } ctx, committer, err := db.TxContext() @@ -99,7 +103,7 @@ func MakeEmailPrimary(email *user_model.EmailAddress) error { func VerifyActiveEmailCode(code, email string) *user_model.EmailAddress { minutes := setting.Service.ActiveCodeLives - if user := getVerifyUser(code); user != nil { + if user := user_model.GetVerifyUser(code); user != nil { // time limit code prefix := code[:base.TimeLimitCodeLength] data := fmt.Sprintf("%d%s%s%s%s", user.ID, email, user.LowerName, user.Passwd, user.Rands) @@ -152,7 +156,7 @@ type SearchEmailResult struct { // SearchEmails takes options i.e. keyword and part of email name to search, // it returns results in given range and number of total results. func SearchEmails(opts *SearchEmailOptions) ([]*SearchEmailResult, int64, error) { - var cond builder.Cond = builder.Eq{"`user`.`type`": UserTypeIndividual} + var cond builder.Cond = builder.Eq{"`user`.`type`": user_model.UserTypeIndividual} if len(opts.Keyword) > 0 { likeStr := "%" + strings.ToLower(opts.Keyword) + "%" cond = cond.And(builder.Or( @@ -236,7 +240,7 @@ func ActivateUserEmail(userID int64, email string, activate bool) (err error) { // Activate/deactivate a user's primary email address and account if addr.IsPrimary { - user := User{ID: userID, Email: email} + user := user_model.User{ID: userID, Email: email} if has, err := sess.Get(&user); err != nil { return err } else if !has { @@ -245,10 +249,10 @@ func ActivateUserEmail(userID int64, email string, activate bool) (err error) { // The user's activation state should be synchronized with the primary email if user.IsActive != activate { user.IsActive = activate - if user.Rands, err = GetUserSalt(); err != nil { + if user.Rands, err = user_model.GetUserSalt(); err != nil { return fmt.Errorf("unable to generate salt: %v", err) } - if err = updateUserCols(sess, &user, "is_active", "rands"); err != nil { + if err = user_model.UpdateUserColsEngine(sess, &user, "is_active", "rands"); err != nil { return fmt.Errorf("unable to updateUserCols() for user ID: %d: %v", userID, err) } } |