Add backend hook to register users
This commit is contained in:
parent
d27a499c07
commit
aa2731e789
1 changed files with 17 additions and 2 deletions
|
@ -97,8 +97,23 @@ func Routes() *chi.Mux {
|
|||
}
|
||||
|
||||
func verify(w http.ResponseWriter, r *http.Request) {
|
||||
token := chi.URLParam(r, "token")
|
||||
fmt.Println(token)
|
||||
returnMessage := ReturnMessage{}
|
||||
_, claims, _ := jwtauth.FromContext(r.Context())
|
||||
sqlStatement := `
|
||||
UPDATE users
|
||||
SET verified = $1
|
||||
WHERE username = $2;`
|
||||
_, err := DB.Exec(sqlStatement, true, claims["username"])
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
returnMessage.Message = "unexpected error verifying account. please contact the administrator"
|
||||
render.JSON(w, r, returnMessage)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
returnMessage.Message = "your email has been verified!"
|
||||
render.JSON(w, r, returnMessage)
|
||||
return
|
||||
}
|
||||
|
||||
func register(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
Reference in a new issue