implement svg interface in login and signup
This commit is contained in:
@@ -28,6 +28,8 @@ func (h *NKodeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
h.LoginHandler(w, r)
|
||||
case api.RenewAttributes:
|
||||
h.RenewAttributesHandler(w, r)
|
||||
case api.RandomSvgInterface:
|
||||
h.RandomSvgInterfaceHandler(w, r)
|
||||
default:
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
_, err := w.Write([]byte("404 not found"))
|
||||
@@ -77,6 +79,7 @@ func (h *NKodeHandler) GenerateSignupInterfaceHandler(w http.ResponseWriter, r *
|
||||
methodNotAllowed(w)
|
||||
return
|
||||
}
|
||||
log.Print("signup interface")
|
||||
|
||||
var signupPost GenerateSignupInterfacePost
|
||||
err := decodeJson(w, r, &signupPost)
|
||||
@@ -95,7 +98,7 @@ func (h *NKodeHandler) GenerateSignupInterfaceHandler(w http.ResponseWriter, r *
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
resp, err := h.Api.GenerateSignupInterface(signupPost.Username, signupPost.CustomerId, kp)
|
||||
resp, err := h.Api.GenerateSignupInterface(signupPost.Username, CustomerId(signupPost.CustomerId), kp)
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
@@ -130,7 +133,7 @@ func (h *NKodeHandler) SetNKodeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
confirmInterface, err := h.Api.SetNKode(setNKodePost.CustomerId, setNKodePost.SessionId, setNKodePost.KeySelection)
|
||||
confirmInterface, err := h.Api.SetNKode(CustomerId(setNKodePost.CustomerId), SessionId(setNKodePost.SessionId), setNKodePost.KeySelection)
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
@@ -168,7 +171,7 @@ func (h *NKodeHandler) ConfirmNKodeHandler(w http.ResponseWriter, r *http.Reques
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
err = h.Api.ConfirmNKode(confirmNKodePost.CustomerId, confirmNKodePost.SessionId, confirmNKodePost.KeySelection)
|
||||
err = h.Api.ConfirmNKode(CustomerId(confirmNKodePost.CustomerId), SessionId(confirmNKodePost.SessionId), confirmNKodePost.KeySelection)
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
@@ -191,15 +194,14 @@ func (h *NKodeHandler) GetLoginInterfaceHandler(w http.ResponseWriter, r *http.R
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
loginInterface, err := h.Api.GetLoginInterface(loginInterfacePost.Username, loginInterfacePost.CustomerId)
|
||||
loginInterface, err := h.Api.GetLoginInterface(loginInterfacePost.Username, CustomerId(loginInterfacePost.CustomerId))
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
respBody := GetLoginInterfaceResp{UserInterface: loginInterface}
|
||||
respBytes, err := json.Marshal(respBody)
|
||||
respBytes, err := json.Marshal(loginInterface)
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
@@ -228,7 +230,7 @@ func (h *NKodeHandler) LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
err = h.Api.Login(loginPost.CustomerId, loginPost.Username, loginPost.KeySelection)
|
||||
err = h.Api.Login(CustomerId(loginPost.CustomerId), loginPost.Username, loginPost.KeySelection)
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
@@ -252,7 +254,35 @@ func (h *NKodeHandler) RenewAttributesHandler(w http.ResponseWriter, r *http.Req
|
||||
return
|
||||
}
|
||||
|
||||
err = h.Api.RenewAttributes(renewAttributesPost.CustomerId)
|
||||
err = h.Api.RenewAttributes(CustomerId(renewAttributesPost.CustomerId))
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func (h *NKodeHandler) RandomSvgInterfaceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
methodNotAllowed(w)
|
||||
}
|
||||
svgs, err := h.Api.RandomSvgInterface()
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
respBody := RandomSvgInterfaceResp{Svgs: svgs}
|
||||
respBytes, err := json.Marshal(respBody)
|
||||
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
_, err = w.Write(respBytes)
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user