mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
added support to login user oauth user by email only (#6330)
* added support to login user oauth user by email only * added sql handler * fixed model method name from GetUserByEmail to GetUserByEmailQuery * fixed variable declaration typo
This commit is contained in:
committed by
Torkel Ödegaard
parent
9badb051ba
commit
eda442dbf9
@@ -19,6 +19,7 @@ func init() {
|
||||
bus.AddHandler("sql", UpdateUser)
|
||||
bus.AddHandler("sql", ChangeUserPassword)
|
||||
bus.AddHandler("sql", GetUserByLogin)
|
||||
bus.AddHandler("sql", GetUserByEmail)
|
||||
bus.AddHandler("sql", SetUsingOrg)
|
||||
bus.AddHandler("sql", GetUserProfile)
|
||||
bus.AddHandler("sql", GetSignedInUser)
|
||||
@@ -193,6 +194,27 @@ func GetUserByLogin(query *m.GetUserByLoginQuery) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetUserByEmail(query *m.GetUserByEmailQuery) error {
|
||||
if query.Email == "" {
|
||||
return m.ErrUserNotFound
|
||||
}
|
||||
|
||||
user := new(m.User)
|
||||
|
||||
user = &m.User{Email: query.Email}
|
||||
has, err := x.Get(user)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if has == false {
|
||||
return m.ErrUserNotFound
|
||||
}
|
||||
|
||||
query.Result = user
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateUser(cmd *m.UpdateUserCommand) error {
|
||||
return inTransaction2(func(sess *session) error {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user