Skip to content

Commit cb5b02d

Browse files
committed
fix: update discord link
fix: redirect link for verification handler (#74) Resolves #70
1 parent 6ca37a0 commit cb5b02d

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We're so excited you're interested in helping with Authorizer! We are happy to h
1010
## Where to ask questions?
1111

1212
1. Check our [Github Issues](https://github.com/authorizerdev/authorizer/issues) to see if someone has already answered your question.
13-
2. Join our community on [Discord](https://discord.gg/WDvCxwkX) and feel free to ask us your questions
13+
2. Join our community on [Discord](https://discord.gg/Zv2D5h6kkK) and feel free to ask us your questions
1414

1515
As you gain experience with Authorizer, please help answer other people's questions! :pray:
1616

@@ -19,7 +19,7 @@ As you gain experience with Authorizer, please help answer other people's questi
1919
You can get started by taking a look at our [Github issues](https://github.com/authorizerdev/authorizer/issues)
2020
If you find one that looks interesting and no one else is already working on it, comment on that issue and start contributing 🙂.
2121

22-
Please ask as many questions as you need, either directly in the issue or on [Discord](https://discord.gg/WDvCxwkX). We're happy to help!:raised_hands:
22+
Please ask as many questions as you need, either directly in the issue or on [Discord](https://discord.gg/Zv2D5h6kkK). We're happy to help!:raised_hands:
2323

2424
### Contributions that are ALWAYS welcome
2525

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- [Getting Started](#getting-started)
1616
- [Contributing](https://github.com/authorizerdev/authorizer/blob/main/.github/CONTRIBUTING.md)
1717
- [Docs](http://docs.authorizer.dev/)
18-
- [Join Community](https://discord.gg/2fXUQN3E)
18+
- [Join Community](https://discord.gg/Zv2D5h6kkK)
1919

2020
# Introduction
2121

server/constants/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var (
1414
JWT_SECRET = ""
1515
ALLOWED_ORIGINS = []string{}
1616
AUTHORIZER_URL = ""
17+
APP_URL = ""
1718
PORT = "8080"
1819
REDIS_URL = ""
1920
IS_PROD = false

server/handlers/verifyEmail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ func VerifyEmailHandler() gin.HandlerFunc {
6969
db.Mgr.SaveSession(sessionData)
7070
}()
7171
utils.SetCookie(c, accessToken)
72-
c.Redirect(http.StatusTemporaryRedirect, claim.Host)
72+
c.Redirect(http.StatusTemporaryRedirect, claim.RedirectURL)
7373
}
7474
}

server/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ func GinContextToContextMiddleware() gin.HandlerFunc {
3232
func CORSMiddleware() gin.HandlerFunc {
3333
return func(c *gin.Context) {
3434
origin := c.Request.Header.Get("Origin")
35+
constants.APP_URL = origin
36+
log.Println("=> APP_URL:", constants.APP_URL)
3537
c.Writer.Header().Set("Access-Control-Allow-Origin", origin)
3638
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
3739
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")

server/utils/cookie.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package utils
22

33
import (
4-
"log"
54
"net/http"
65

76
"github.com/authorizerdev/authorizer/server/constants"
@@ -11,9 +10,8 @@ import (
1110
func SetCookie(gc *gin.Context, token string) {
1211
secure := true
1312
httpOnly := true
14-
1513
host := GetHostName(constants.AUTHORIZER_URL)
16-
log.Println("=> cookie host", host)
14+
1715
gc.SetSameSite(http.SameSiteNoneMode)
1816
gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", host, secure, httpOnly)
1917
}
@@ -31,11 +29,8 @@ func DeleteCookie(gc *gin.Context) {
3129
secure := true
3230
httpOnly := true
3331

34-
if !constants.IS_PROD {
35-
secure = false
36-
}
37-
3832
host := GetHostName(constants.AUTHORIZER_URL)
33+
3934
gc.SetSameSite(http.SameSiteNoneMode)
4035
gc.SetCookie(constants.COOKIE_NAME, "", -1, "/", host, secure, httpOnly)
4136
}

server/utils/urls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strings"
66
)
77

8-
// function to get hostname
8+
// GetHostName function to get hostname
99
func GetHostName(auth_url string) string {
1010
u, err := url.Parse(auth_url)
1111
if err != nil {

server/utils/verificationToken.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import (
88
)
99

1010
type UserInfo struct {
11-
Email string `json:"email"`
12-
Host string `json:"host"`
11+
Email string `json:"email"`
12+
Host string `json:"host"`
13+
RedirectURL string `json:"redirect_url"`
1314
}
1415

1516
type CustomClaim struct {
@@ -28,7 +29,7 @@ func CreateVerificationToken(email string, tokenType string) (string, error) {
2829
ExpiresAt: time.Now().Add(time.Minute * 30).Unix(),
2930
},
3031
tokenType,
31-
UserInfo{Email: email, Host: constants.AUTHORIZER_URL},
32+
UserInfo{Email: email, Host: constants.AUTHORIZER_URL, RedirectURL: constants.APP_URL},
3233
}
3334

3435
return t.SignedString([]byte(constants.JWT_SECRET))

0 commit comments

Comments
 (0)