Skip to content

Commit eec0ee4

Browse files
committed
Fix issue with sign in api
1 parent 304148b commit eec0ee4

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

recipe/dashboard/api/signInPost.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,35 @@ type signInRequestBody struct {
1717
Password *string `json:"password"`
1818
}
1919

20-
func SignInPost(apiInterface dashboardmodels.APIInterface, options dashboardmodels.APIOptions) (signInPostResponse, error) {
20+
func SignInPost(apiInterface dashboardmodels.APIInterface, options dashboardmodels.APIOptions) error {
2121
body, err := supertokens.ReadFromRequest(options.Req)
2222

2323
if err != nil {
24-
return signInPostResponse{}, err
24+
return err
2525
}
2626

2727
var readBody signInRequestBody
2828
err = json.Unmarshal(body, &readBody)
2929
if err != nil {
30-
return signInPostResponse{}, err
30+
return err
3131
}
3232

3333
if readBody.Email == nil {
34-
return signInPostResponse{}, supertokens.BadInputError{
34+
return supertokens.BadInputError{
3535
Msg: "Required parameter 'email' is missing",
3636
}
3737
}
3838

3939
if readBody.Password == nil {
40-
return signInPostResponse{}, supertokens.BadInputError{
40+
return supertokens.BadInputError{
4141
Msg: "Required parameter 'password' is missing",
4242
}
4343
}
4444

4545
querier, querierErr := supertokens.GetNewQuerierInstanceOrThrowError("dashboard")
4646

4747
if querierErr != nil {
48-
return signInPostResponse{}, querierErr
48+
return querierErr
4949
}
5050

5151
apiResponse, apiErr := querier.SendPostRequest("/recipe/dashboard/signin", map[string]interface{}{
@@ -54,26 +54,26 @@ func SignInPost(apiInterface dashboardmodels.APIInterface, options dashboardmode
5454
})
5555

5656
if apiErr != nil {
57-
return signInPostResponse{}, apiErr
57+
return apiErr
5858
}
5959

6060
status, ok := apiResponse["status"]
6161

6262
if ok && status == "OK" {
63-
return signInPostResponse{
64-
Status: "OK",
65-
SessionId: apiResponse["sessionId"].(string),
66-
}, nil
63+
return supertokens.Send200Response(options.Res, map[string]interface{}{
64+
"status": "OK",
65+
"sessionId": apiResponse["sessionId"].(string),
66+
})
6767
}
6868

6969
if status == "USER_SUSPENDED_ERROR" {
70-
return signInPostResponse{
71-
Status: "USER_SUSPENDED_ERROR",
72-
Message: apiResponse["message"].(string),
73-
}, nil
70+
return supertokens.Send200Response(options.Res, map[string]interface{}{
71+
"status": "USER_SUSPENDED_ERROR",
72+
"message": apiResponse["message"].(string),
73+
})
7474
}
7575

76-
return signInPostResponse{
77-
Status: "INVAlID_CREDENTIALS_ERROR",
78-
}, nil
76+
return supertokens.Send200Response(options.Res, map[string]interface{}{
77+
"status": "INVAlID_CREDENTIALS_ERROR",
78+
})
7979
}

recipe/dashboard/recipe.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ func (r *Recipe) handleAPIRequest(id string, req *http.Request, res http.Respons
112112
return api.Dashboard(r.APIImpl, options)
113113
} else if id == validateKeyAPI {
114114
return api.ValidateKey(r.APIImpl, options)
115+
} else if id == signInAPI {
116+
return api.SignInPost(r.APIImpl, options)
115117
}
116118

117119
// Do API key validation for the remaining APIs
@@ -161,8 +163,6 @@ func (r *Recipe) handleAPIRequest(id string, req *http.Request, res http.Respons
161163
return userdetails.UserEmailVerifyTokenPost(r.APIImpl, options)
162164
} else if id == userPasswordAPI {
163165
return userdetails.UserPasswordPut(r.APIImpl, options)
164-
} else if id == signInAPI {
165-
return api.SignInPost(r.APIImpl, options)
166166
} else if id == signOutAPI {
167167
return api.SignOutPost(r.APIImpl, options)
168168
}

0 commit comments

Comments
 (0)