Skip to content

Commit

Permalink
Add support for email & phone number login / signup
Browse files Browse the repository at this point in the history
  • Loading branch information
lakhansamani committed Oct 27, 2023
1 parent 32377dc commit 0ca850c
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions examples/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ const (
// Authorizer server endpoint
AuthorizerURL = "http://localhost:8080"
)

var (
// Test email
TestEmail = "[email protected]"
)
2 changes: 1 addition & 1 deletion examples/deactivate_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func DeactivateAccountExample() {
}

loginRes, err := c.Login(&authorizer.LoginInput{
Email: "[email protected]",
Email: &TestEmail,
Password: "Abc@123",
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/get_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func GetProfileExample() {
}

loginRes, err := c.Login(&authorizer.LoginInput{
Email: "[email protected]",
Email: &TestEmail,
Password: "Abc@123",
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/get_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func GetSessionExample() {
}

loginRes, err := c.Login(&authorizer.LoginInput{
Email: "[email protected]",
Email: &TestEmail,
Password: "Abc@123",
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func LoginExample() {
}

res, err := c.Login(&authorizer.LoginInput{
Email: "[email protected]",
Email: &TestEmail,
Password: "Abc@123",
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func LogoutExample() {
}

loginRes, err := c.Login(&authorizer.LoginInput{
Email: "[email protected]",
Email: &TestEmail,
Password: "Abc@123",
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions examples/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package examples

import (
"fmt"
"time"

"github.com/authorizerdev/authorizer-go"
)
Expand All @@ -15,7 +14,7 @@ func SignUpExample() {
}

res, err := c.SignUp(&authorizer.SignUpInput{
Email: fmt.Sprintf("test.%[email protected]", time.Now().Unix()),
Email: &TestEmail,
Password: "Abc@123",
ConfirmPassword: "Abc@123",
})
Expand Down
2 changes: 1 addition & 1 deletion examples/update_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func UpdateProfileExample() {
}

loginRes, err := c.Login(&authorizer.LoginInput{
Email: "[email protected]",
Email: &TestEmail,
Password: "Abc@123",
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/validate_jwt_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func ValidateJWTTokenExample() {
}

loginRes, err := c.Login(&authorizer.LoginInput{
Email: "[email protected]",
Email: &TestEmail,
Password: "Abc@123",
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/validate_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func ValidateSessionExample() {
panic(err)
}
_, err = c.Login(&authorizer.LoginInput{
Email: "[email protected]",
Email: &TestEmail,
Password: "Abc@123",
})
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions login.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (

// LoginInput defines attributes for login request
type LoginInput struct {
Email string `json:"email"`
Password string `json:"password"`
Roles []*string `json:"roles,omitempty"`
Scope []*string `json:"scope,omitempty"`
Email *string `json:"email,omitempty"`
PhoneNumber *string `json:"phone_number,omitempty"`
Password string `json:"password"`
Roles []*string `json:"roles,omitempty"`
Scope []*string `json:"scope,omitempty"`
}

// Login is method attached to AuthorizerClient.
Expand Down
2 changes: 1 addition & 1 deletion signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// SignUpInput defines attributes for signup request
type SignUpInput struct {
Email string `json:"email"`
Email *string `json:"email,omitempty"`
Password string `json:"password"`
ConfirmPassword string `json:"confirm_password"`
GivenName *string `json:"given_name,omitempty"`
Expand Down

0 comments on commit 0ca850c

Please sign in to comment.