diff --git a/api/s5.go b/api/s5.go index b5274e6..31b4686 100644 --- a/api/s5.go +++ b/api/s5.go @@ -33,5 +33,6 @@ func getRoutes(h *s5.HttpHandler, portal interfaces.Portal) map[string]jape.Hand "POST /s5/account/register": h.AccountRegister, "GET /s5/account/login": h.AccountLoginChallenge, "POST /s5/account/login": h.AccountLogin, + "GET /s5/account": s5.AuthMiddleware(h.AccountInfo, portal), } } diff --git a/api/s5/http.go b/api/s5/http.go index a2d763e..e4341a6 100644 --- a/api/s5/http.go +++ b/api/s5/http.go @@ -518,6 +518,20 @@ func (h *HttpHandler) AccountLogin(jc jape.Context) { setAuthCookie(jwt, jc) } +func (h *HttpHandler) AccountInfo(jc jape.Context) { + _, user := h.portal.Accounts().AccountExists(jc.Request.Context().Value(AuthUserIDKey).(uint64)) + + info := &AccountInfoResponse{ + Email: user.Email, + QuotaExceeded: false, + EmailConfirmed: false, + IsRestricted: false, + Tier: 0, + } + + jc.Encode(info) +} + func setAuthCookie(jwt string, jc jape.Context) { authCookie := http.Cookie{ Name: "s5-auth-token", diff --git a/api/s5/messages.go b/api/s5/messages.go index 0b4021b..fce0470 100644 --- a/api/s5/messages.go +++ b/api/s5/messages.go @@ -22,3 +22,10 @@ type AccountLoginRequest struct { type AccountLoginChallengeResponse struct { Challenge string `json:"challenge"` } +type AccountInfoResponse struct { + Email string `json:"email"` + QuotaExceeded bool `json:"quotaExceeded"` + EmailConfirmed bool `json:"emailConfirmed"` + IsRestricted bool `json:"isRestricted"` + Tier uint8 `json:"tier"` +}