mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 17:29:54 +01:00
Registration
This commit is contained in:
31
ober.go
31
ober.go
@@ -86,7 +86,36 @@ func Register(ctx *fasthttp.RequestCtx) {
|
||||
ctx.SetStatusCode(fasthttp.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
// TODO REGISTER
|
||||
// check user exists
|
||||
_, err = ReadUser(register.Username)
|
||||
if err == nil {
|
||||
ctx.WriteString("Nicht drängeln")
|
||||
ctx.SetStatusCode(fasthttp.StatusConflict)
|
||||
return
|
||||
}
|
||||
// check user legit
|
||||
userData, _, err := GetUserData(register.Username)
|
||||
if err != nil {
|
||||
ctx.WriteString(err.Error())
|
||||
ctx.SetStatusCode(fasthttp.StatusExpectationFailed)
|
||||
return
|
||||
}
|
||||
if userData.Data.MalID != register.MalId {
|
||||
ctx.WriteString("Dich gibts net auf MAL")
|
||||
ctx.SetStatusCode(fasthttp.StatusExpectationFailed)
|
||||
return
|
||||
}
|
||||
// REGISTER
|
||||
user := UserData{
|
||||
Username: register.Username,
|
||||
MalId: register.MalId,
|
||||
}
|
||||
err = SaveUser(&user)
|
||||
if err != nil {
|
||||
addErrorToCtx(ctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.SetBody(body)
|
||||
ctx.SetStatusCode(fasthttp.StatusOK)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user