Skip to content

Commit 89c9465

Browse files
committed
nit: add empty line
1 parent 9240f59 commit 89c9465

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

api/mfa.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ func HandlePostMFAFlow(c *gin.Context) {
8383
csrfToken := req_body.CsrfToken
8484
cookie := strings.Split(flow_cookie, ";")[0] + "; " + strings.Split(session_cookie, ";")[0] + "; x-csrf-token=" + csrfToken
8585

86-
identity, session, err := login.SubmitLoginWithMFAWrapper(cookie, req_body.FlowID, req_body.CsrfToken, req_body.TOTP)
86+
identity, session, errMsg, err := login.SubmitLoginWithMFAWrapper(cookie, req_body.FlowID, req_body.CsrfToken, req_body.TOTP)
8787

8888
if err != nil {
8989
log.ErrorLogger("Kratos post MFA flow failed", err)
9090
c.JSON(http.StatusInternalServerError, gin.H{
91-
"error": "internal server error",
91+
"error": "MFA Failed",
92+
"message": errMsg,
9293
})
9394
return
9495
}

api/recovery.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func HandlePostRecoveryCodeFlow(c *gin.Context) {
104104
return
105105
}
106106

107-
session, err := recovery.SubmitRecoveryCodeFlowWrapper(cookie, t.FlowID, t.CsrfToken, t.RecoveryCode)
107+
session, errMsg, err := recovery.SubmitRecoveryCodeFlowWrapper(cookie, t.FlowID, t.CsrfToken, t.RecoveryCode)
108108

109109
if err != nil {
110110
log.ErrorLogger("POST Recovery flow failed", err)
@@ -116,6 +116,14 @@ func HandlePostRecoveryCodeFlow(c *gin.Context) {
116116
return
117117
}
118118

119+
if session == "" {
120+
c.JSON(http.StatusBadRequest, gin.H{
121+
"error": errMsg,
122+
"message": "POST Recovery Code flow failed",
123+
})
124+
return
125+
}
126+
119127
c.SetCookie("sdslabs_session", session, 3600, "/", config.NymeriaConfig.URL.Domain, true, true)
120128

121129
c.JSON(http.StatusOK, gin.H{

api/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func HandleChangePassword(c *gin.Context) {
206206
errCode := helper.ExtractErrorCode(err)
207207
c.JSON(errCode, gin.H{
208208
"error": err.Error(),
209-
"message": "Kratos post settings change password flow failed",
209+
"message": msg,
210210
})
211211
return
212212
}

helper/extracter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,6 @@ func ExtractErrorMessage(r *http.Response) string {
157157
msg += message.Text + ", "
158158
}
159159
}
160+
160161
return strings.Trim(msg, ", ")
161162
}

helper/types.go

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,59 @@
11
package helper
22

33
type KratosHttpResponseBody struct {
4-
ID string `json:"id"`
5-
Type string `json:"type"`
6-
ExpiresAt string `json:"expires_at"`
7-
IssuedAt string `json:"issued_at"`
8-
RequestURL string `json:"request_url"`
9-
UI KratosHttpReponseUI `json:"ui"`
10-
OrganizationID *string `json:"organization_id"`
11-
State string `json:"state"`
4+
ID string `json:"id"`
5+
Type string `json:"type"`
6+
ExpiresAt string `json:"expires_at"`
7+
IssuedAt string `json:"issued_at"`
8+
RequestURL string `json:"request_url"`
9+
UI KratosHttpResponseUI `json:"ui"`
10+
OrganizationID *string `json:"organization_id"`
11+
State string `json:"state"`
12+
Active string `json:"active,omitempty"`
13+
TransientPayload interface{} `json:"transient_payload,omitempty"`
1214
}
1315

14-
type KratosHttpReponseUI struct {
15-
Action string `json:"action"`
16-
Method string `json:"method"`
17-
Nodes []KratosHttpResponseNode `json:"nodes"`
18-
Messages []KratosHttpReponseMessage `json:"messages"`
16+
type KratosHttpResponseUI struct {
17+
Action string `json:"action"`
18+
Method string `json:"method"`
19+
Nodes []KratosHttpResponseNode `json:"nodes"`
20+
Messages []KratosHttpResponseMessage `json:"messages"`
1921
}
2022

2123
type KratosHttpResponseNode struct {
2224
Type string `json:"type"`
2325
Group string `json:"group"`
2426
Attributes KratosHttpResponseAttributes `json:"attributes"`
25-
Messages []KratosHttpReponseMessage `json:"messages"`
27+
Messages []KratosHttpResponseMessage `json:"messages"`
2628
Meta KratosHttpResponseMeta `json:"meta"`
2729
}
2830

2931
type KratosHttpResponseAttributes struct {
3032
Name string `json:"name"`
3133
Type string `json:"type"`
32-
Value interface{} `json:"value"` // Can be string, boolean, or other types
34+
Value interface{} `json:"value"`
3335
Required bool `json:"required,omitempty"`
3436
Disabled bool `json:"disabled,omitempty"`
3537
NodeType string `json:"node_type"`
3638
Autocomplete string `json:"autocomplete,omitempty"`
39+
Maxlength int `json:"maxlength,omitempty"`
40+
Pattern string `json:"pattern,omitempty"`
3741
}
3842

39-
type KratosHttpReponseMessage struct {
43+
type KratosHttpResponseMessage struct {
4044
ID int `json:"id"`
4145
Text string `json:"text"`
4246
Type string `json:"type"`
43-
Context map[string]interface{} `json:"context"`
47+
Context map[string]interface{} `json:"context,omitempty"`
4448
}
4549

4650
type KratosHttpResponseMeta struct {
47-
Label *KratosHttpResponseLabel `json:"label"`
51+
Label *KratosHttpResponseLabel `json:"label,omitempty"`
4852
}
4953

5054
type KratosHttpResponseLabel struct {
5155
ID int `json:"id"`
5256
Text string `json:"text"`
5357
Type string `json:"type"`
54-
Context map[string]interface{} `json:"context"`
58+
Context map[string]interface{} `json:"context,omitempty"`
5559
}

0 commit comments

Comments
 (0)