mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
error handling
This commit is contained in:
parent
65847da1df
commit
c4168c2396
@ -29,9 +29,12 @@ func GetUserByAuthInfo(query *m.GetUserByAuthInfoQuery) error {
|
|||||||
err = GetAuthInfo(authQuery)
|
err = GetAuthInfo(authQuery)
|
||||||
// if user id was specified and doesn't match the user_auth entry, remove it
|
// if user id was specified and doesn't match the user_auth entry, remove it
|
||||||
if err == nil && query.UserId != 0 && query.UserId != authQuery.Result.UserId {
|
if err == nil && query.UserId != 0 && query.UserId != authQuery.Result.UserId {
|
||||||
DeleteAuthInfo(&m.DeleteAuthInfoCommand{
|
err = DeleteAuthInfo(&m.DeleteAuthInfoCommand{
|
||||||
UserAuth: authQuery.Result,
|
UserAuth: authQuery.Result,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
sqlog.Error("Error removing user_auth entry", "error", err)
|
||||||
|
}
|
||||||
} else if err == nil {
|
} else if err == nil {
|
||||||
has, err = x.Id(authQuery.Result.UserId).Get(user)
|
has, err = x.Id(authQuery.Result.UserId).Get(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -42,9 +45,12 @@ func GetUserByAuthInfo(query *m.GetUserByAuthInfoQuery) error {
|
|||||||
query.UserAuth = authQuery.Result
|
query.UserAuth = authQuery.Result
|
||||||
} else {
|
} else {
|
||||||
// if the user has been deleted then remove the entry
|
// if the user has been deleted then remove the entry
|
||||||
DeleteAuthInfo(&m.DeleteAuthInfoCommand{
|
err = DeleteAuthInfo(&m.DeleteAuthInfoCommand{
|
||||||
UserAuth: authQuery.Result,
|
UserAuth: authQuery.Result,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
sqlog.Error("Error removing user_auth entry", "error", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if err != m.ErrUserNotFound {
|
} else if err != m.ErrUserNotFound {
|
||||||
return err
|
return err
|
||||||
@ -113,21 +119,13 @@ func SetAuthInfo(cmd *m.SetAuthInfoCommand) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, err := sess.Insert(&authUser)
|
_, err := sess.Insert(&authUser)
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteAuthInfo(cmd *m.DeleteAuthInfoCommand) error {
|
func DeleteAuthInfo(cmd *m.DeleteAuthInfoCommand) error {
|
||||||
return inTransaction(func(sess *DBSession) error {
|
return inTransaction(func(sess *DBSession) error {
|
||||||
_, err := sess.Delete(cmd.UserAuth)
|
_, err := sess.Delete(cmd.UserAuth)
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user