add better return on invalid username / email on registration #28

Open
opened 2022-04-07 21:25:29 +00:00 by MCWertGaming · 3 comments
MCWertGaming commented 2022-04-07 21:25:29 +00:00 (Migrated from github.com)

Currently authfox is sending the code 402 (I think) when the registration receives wrong / taken user names and passwords. We should change that to sending 200 (OK) and then doing the verification if the registrations worked in the json payload. When the registration didn't worked we also need to add a small message with the reason. Like "Password must be over 6 characters long".

When a username or email is taken, it returns 500 currently. We should send an info to the front-end instead.

Currently authfox is sending the code 402 (I think) when the registration receives wrong / taken user names and passwords. We should change that to sending 200 (OK) and then doing the verification if the registrations worked in the json payload. When the registration didn't worked we also need to add a small message with the reason. Like "Password must be over 6 characters long". When a username or email is taken, it returns 500 currently. We should send an info to the front-end instead.
fwuffyboi commented 2022-05-12 05:58:43 +00:00 (Migrated from github.com)

On it!
Also, wdym by "then doing the verification if the registrations worked in the json payload."?

On it! Also, wdym by "then doing the verification if the registrations worked in the json payload."?
MCWertGaming commented 2022-05-12 12:36:47 +00:00 (Migrated from github.com)

Basically the small function I wrote in the register.go source must me moved into the code (or you add the messages as parameters) and when a check fails you need to send 200 (http.StatusOK) and a json.

type wrongDataReturn struct{
    status bool `json:status` // indicates if the account creation worked
    message string `json:message` // the reason why it didn't worked so we can display it on the registration prompt
    messageShort string `json:message_short` // a short version of message for debugging / internal use
}

This is something I coded in the GitHub comment section, so just do something like that. Then you simply send the struct as json via gin:

c.JSON{http.StatusOK, your_struct}

And that should be it. Thank you really much for looking into this!

Basically the small function I wrote in the `register.go` source must me moved into the code (or you add the messages as parameters) and when a check fails you need to send `200` (http.StatusOK) and a json. ```go type wrongDataReturn struct{ status bool `json:status` // indicates if the account creation worked message string `json:message` // the reason why it didn't worked so we can display it on the registration prompt messageShort string `json:message_short` // a short version of message for debugging / internal use } ``` This is something I coded in the GitHub comment section, so just do something like that. Then you simply send the struct as json via gin: ``` c.JSON{http.StatusOK, your_struct} ``` And that should be it. Thank you really much for looking into this!
fwuffyboi commented 2022-05-12 13:51:07 +00:00 (Migrated from github.com)

Ah. Thank you @MCWertGaming that cleared some stuff up! Thx.

Ah. Thank you @MCWertGaming that cleared some stuff up! Thx.
Commenting is not possible because the repository is archived.
No description provided.