User information
This commit is contained in:
@@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `games` (
|
||||
`name` varchar(255) NOT NULL DEFAULT '0',
|
||||
`revision` bigint unsigned NOT NULL DEFAULT '0',
|
||||
`path_storage` text NOT NULL,
|
||||
`hash` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
|
||||
`hash` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
|
||||
`last_update` datetime DEFAULT NULL,
|
||||
`user_id` bigint unsigned NOT NULL DEFAULT '0',
|
||||
`available` tinyint unsigned NOT NULL DEFAULT '0',
|
||||
|
||||
@@ -221,3 +221,19 @@ func Download(w http.ResponseWriter, r *http.Request) {
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
func UserInformation(w http.ResponseWriter, r *http.Request) {
|
||||
userId, err := userIdFromContext(r.Context())
|
||||
if err != nil {
|
||||
internalServerError(w, r)
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
user, err := database.UserById(userId)
|
||||
if err != nil {
|
||||
internalServerError(w, r)
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
ok(user, w, r)
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ func Serve() {
|
||||
}
|
||||
r.Route("/system", func(systemRouter chi.Router) {
|
||||
systemRouter.Get("/information", Information)
|
||||
|
||||
})
|
||||
r.Route("/user", func(secureRouter chi.Router) {
|
||||
secureRouter.Use(authMiddleware)
|
||||
secureRouter.Get("/information", UserInformation)
|
||||
})
|
||||
r.Route("/game", func(secureRouter chi.Router) {
|
||||
secureRouter.Use(authMiddleware)
|
||||
|
||||
Reference in New Issue
Block a user