Skip to content

Commit

Permalink
add function to get verification status
Browse files Browse the repository at this point in the history
  • Loading branch information
pratham1729 committed Aug 18, 2024
1 parent 7f2b6dd commit 89f3e8f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Start() {
r.POST("/verification", HandlePostVerificationFlow)

r.POST("/get_profile", HandlePostProfile)
r.POST("/get_verified_status", HandleGetVerifiedStatus)
r.POST("/verify_app", middleware.HandleAppAuthorization, func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "Authorized",
Expand Down
18 changes: 18 additions & 0 deletions api/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,21 @@ func HandlePostProfile(c *gin.Context) {

c.JSON(http.StatusOK, profile)
}

func HandleGetVerifiedStatus(c *gin.Context) {
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()
verifiableAddresses := identity.GetVerifiableAddresses()
emails := verifiableAddresses

c.JSON(http.StatusOK, emails)
}
13 changes: 13 additions & 0 deletions api/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package api

import "time"

type ApplicationPostBody struct {
Name string `json:"name"`
RedirectURL string `json:"redirect_url"`
Expand All @@ -22,3 +24,14 @@ type ApplicationBody struct {
type IdentityBody struct {
Identity string `json:"identity"`
}

type VerifiableIdentityAddress struct {
CreatedAt *time.Time `json:"created_at,omitempty"`
Id *string `json:"id,omitempty"`
Status string `json:"status"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
Value string `json:"value"`
Verified bool `json:"verified"`
VerifiedAt *time.Time `json:"verified_at,omitempty"`
Via string `json:"via"`
}

0 comments on commit 89f3e8f

Please sign in to comment.