Skip to content

Commit

Permalink
adds unlink account in recipe impl - tests remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Dec 13, 2023
1 parent 67eded3 commit c7b7d50
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions supertokens/accountlinkingRecipeImplementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,20 @@ func makeRecipeImplementation(querier Querier, config AccountLinkingTypeNormalis
}
}

unlinkAccounts := func(recipeUserId RecipeUserID, userContext UserContext) (UnlinkAccountsResponse, error) {
requestBody := map[string]interface{}{
"recipeUserId": recipeUserId.GetAsString(),
}
resp, err := querier.SendPostRequest("/recipe/accountlinking/user/unlink", requestBody, userContext)
if err != nil {
return UnlinkAccountsResponse{}, err
}
return UnlinkAccountsResponse{
WasRecipeUserDeleted: resp["wasRecipeUserDeleted"].(bool),
WasLinked: resp["wasLinked"].(bool),
}, nil
}

// TODO:...
return AccountLinkingRecipeInterface{
GetUsersWithSearchParams: &getUsers,
Expand All @@ -331,5 +345,6 @@ func makeRecipeImplementation(querier Querier, config AccountLinkingTypeNormalis
CreatePrimaryUser: &createPrimaryUser,
LinkAccounts: &linkAccounts,
CanLinkAccounts: &canLinkAccounts,
UnlinkAccounts: &unlinkAccounts,
}
}
13 changes: 13 additions & 0 deletions supertokens/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,16 @@ func CanLinkAccounts(recipeUserId RecipeUserID, primaryUserId string, userContex

return (*accountLinkingInstance.RecipeImpl.CanLinkAccounts)(recipeUserId, primaryUserId, userContext[0])
}

func UnlinkAccounts(recipeUserId RecipeUserID, userContext ...UserContext) (UnlinkAccountsResponse, error) {
accountLinkingInstance, err := getAccountLinkingRecipeInstanceOrThrowError()
if err != nil {
return UnlinkAccountsResponse{}, err
}

if len(userContext) == 0 {
userContext = append(userContext, &map[string]interface{}{})
}

return (*accountLinkingInstance.RecipeImpl.UnlinkAccounts)(recipeUserId, userContext[0])
}

0 comments on commit c7b7d50

Please sign in to comment.