Skip to content

Commit

Permalink
Return auth token in login mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
hlubek committed Jul 22, 2024
1 parent 7b6cd99 commit e8a3365
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion backend/api/graph/authentication.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions backend/api/graph/helper/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import (
"myvendor.mytld/myproject/backend/security/authentication"
)

func SetAuthTokenCookieForAccount(ctx context.Context, account authentication.AuthTokenDataProvider, timeSource domain.TimeSource, extendedExpiry bool) (csrfToken string, err error) {
func SetAuthTokenCookieForAccount(ctx context.Context, account authentication.AuthTokenDataProvider, timeSource domain.TimeSource, extendedExpiry bool) (authToken string, csrfToken string, err error) {
tokenOpts := authentication.TokenOptsForAccount(account, extendedExpiry)
authToken, err := authentication.GenerateAuthToken(account, timeSource, tokenOpts)
authToken, err = authentication.GenerateAuthToken(account, timeSource, tokenOpts)
if err != nil {
return "", fog_errors.Wrap(err, "generating auth token")
return "", "", fog_errors.Wrap(err, "generating auth token")
}

csrfToken, err = authentication.GenerateCsrfToken(account, timeSource, tokenOpts)
if err != nil {
return "", fog_errors.Wrap(err, "generating CSRF token")
return "", "", fog_errors.Wrap(err, "generating CSRF token")
}

req := api.GetHTTPRequest(ctx)
w := api.GetHTTPResponse(ctx)
authentication.SetAuthTokenCookie(w, req, authToken)

return csrfToken, nil
return authToken, csrfToken, nil
}
3 changes: 2 additions & 1 deletion devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"cd docs",
". $VENV_DIR/bin/activate",
"mkdocs serve"
]
],
"goland:setup": "sed -i 's#\\(<component name=\"GOROOT\" url=\\)\"[^\"]*\"#\\1\"file://\\$PROJECT_DIR\\$/.devbox/nix/profile/default/share/go\"#' .idea/workspace.xml"
}
},
"env": {
Expand Down

0 comments on commit e8a3365

Please sign in to comment.