Skip to content

Commit

Permalink
remove verified trait
Browse files Browse the repository at this point in the history
  • Loading branch information
pratham1729 committed Aug 18, 2024
1 parent 0711f2e commit 93f972c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 48 deletions.
47 changes: 10 additions & 37 deletions api/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,16 @@ func HandleGetSettingsFlow(c *gin.Context) {
identity := session.GetIdentity()
traits := identity.GetTraits().(map[string]interface{})

if identity.VerifiableAddresses[0].Verified && traits["verified"] == false {
traits["verified"] = true

_, err = settings.SubmitSettingsFlowProfileMethod(flow_cookie, session_cookie, flowID, csrf_token, traits)
if err != nil {
log.ErrorLogger("Kratos post settings update profile flow failed", err)

errCode, _ := strconv.Atoi((strings.Split(err.Error(), " "))[0])
c.JSON(errCode, gin.H{
"error": err.Error(),
"message": "Kratos post settings update profile flow failed",
})
return
}
_, err = settings.SubmitSettingsFlowProfileMethod(flow_cookie, session_cookie, flowID, csrf_token, traits)
if err != nil {
log.ErrorLogger("Kratos post settings update profile flow failed", err)

errCode, _ := strconv.Atoi((strings.Split(err.Error(), " "))[0])
c.JSON(errCode, gin.H{
"error": err.Error(),
"message": "Kratos post settings update profile flow failed",
})
return
}

c.JSON(http.StatusOK, gin.H{
Expand All @@ -129,7 +125,6 @@ func HandleUpdateProfile(c *gin.Context) {
"img_url": req_body.Traits.ImgURL,
"phone_number": req_body.Traits.PhoneNumber,
"invite_status": req_body.Traits.InviteStatus,
"verified": req_body.Traits.Verified,
"role": req_body.Traits.Role,
"created_at": req_body.Traits.Created_At,
"totp_enabled": req_body.Traits.TOTP_Enabled,
Expand Down Expand Up @@ -170,25 +165,6 @@ func HandleUpdateProfile(c *gin.Context) {
return
}

//Checking if email is changed then verified will be false
session, err := middleware.GetSession(c)
if err != nil {
log.ErrorLogger("Unable to get session", err)
errCode, _ := strconv.Atoi(strings.Split(err.Error(), " ")[0])
c.JSON(errCode, gin.H{
"error": err.Error(),
"message": "Unable to get session",
})
return
}
identity := session.GetIdentity()
traits := identity.GetTraits()
profile := traits.(map[string]interface{})

if profile["email"] != traitsinterface["email"] {
traitsinterface["verified"] = false
}

msg, err := settings.SubmitSettingsFlowProfileMethod(flow_cookie, session_cookie, req_body.FlowID, req_body.CsrfToken, traitsinterface)

if err != nil {
Expand Down Expand Up @@ -278,9 +254,6 @@ func HandleChangePassword(c *gin.Context) {
profile["password"] = req_body.Password

if recovery_cookie != "" {
if profile["verified"] == false {
profile["verified"] = true
}
if profile["invite_status"] == "pending" {
profile["invite_status"] = "accepted"
}
Expand Down
1 change: 0 additions & 1 deletion pkg/wrapper/kratos/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func CreateIdentityFlowWrapper(data Identity) (*client.Identity, *http.Response,
"phone_number": data.PhoneNumber,
"img_url": data.ImgURL,
"invite_status": "pending",
"verified": false,
"role": data.Role,
"created_at": timeStamp,
"totp_enabled": false,
Expand Down
1 change: 0 additions & 1 deletion pkg/wrapper/kratos/registration/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func SubmitRegistrationFlowWrapper(cookie string, flowID string, csrfToken strin
"img_url": data.ImgURL,
"phone_number": data.PhoneNumber,
"invite_status": "self_created",
"verified": false,
"role": "user",
"created_at": timeStamp,
"totp_enabled": false,
Expand Down
1 change: 0 additions & 1 deletion pkg/wrapper/kratos/settings/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type Traits struct {
ImgURL string `json:"img_url,omitempty"`
PhoneNumber string `json:"phone_number"`
InviteStatus string `json:"invite_status"`
Verified bool `json:"verified"`
Role string `json:"role"`
Created_At string `json:"created_at"`
TOTP_Enabled bool `json:"totp_enabled"`
Expand Down
4 changes: 0 additions & 4 deletions schema/identity.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
"type": "boolean",
"title": "Active"
},
"verified": {
"type": "integer",
"title": "Verified"
},
"isAdmin":{
"type": "boolean",
"title": "Role"
Expand Down
4 changes: 0 additions & 4 deletions schema/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
"type": "boolean",
"title": "Active"
},
"verified": {
"type": "integer",
"title": "Verified"
},
"created_at": {
"type": "string",
"format": "date-time",
Expand Down

0 comments on commit 93f972c

Please sign in to comment.