mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Add getUserProfile and database.IsBanned
This commit is contained in:
parent
44eb1e1fa6
commit
53a764e8bb
13 changed files with 328 additions and 163 deletions
|
@ -42,3 +42,20 @@ func SendAuthorizationError(f func(db database.AppDatabase, uid string) (reqcont
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func SendErrorIfNotLoggedIn(f func(db database.AppDatabase) (reqcontext.AuthStatus, error), db database.AppDatabase, w http.ResponseWriter, l logrus.FieldLogger) bool {
|
||||
|
||||
auth, err := f(db)
|
||||
|
||||
if err != nil {
|
||||
helpers.SendInternalError(err, "Authorization error", w, l)
|
||||
return false
|
||||
}
|
||||
|
||||
if auth == reqcontext.UNAUTHORIZED {
|
||||
helpers.SendStatus(http.StatusUnauthorized, w, "Unauthorized", l)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue