Add getUserProfile and database.IsBanned

This commit is contained in:
Marco Realacci 2022-11-21 19:44:50 +01:00
parent 44eb1e1fa6
commit 53a764e8bb
13 changed files with 328 additions and 163 deletions

View file

@ -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
}