aboutsummaryrefslogtreecommitdiff
path: root/service/auth.go
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-05-29 13:28:42 +0000
committerr <r@freesoftwareextremist.com>2020-05-29 16:02:26 +0000
commit61fbb24db82a24a558933abcfadff286f524c207 (patch)
tree1f5419028287267cd6b08fc5409bc3d2c5b7d74e /service/auth.go
parent1ae3c33b7df83cec8afdb5f8e3cc46a0919c9ac1 (diff)
downloadbloat-61fbb24db82a24a558933abcfadff286f524c207.tar.gz
bloat-61fbb24db82a24a558933abcfadff286f524c207.zip
Fix signin page redirection in single instance mode
Diffstat (limited to 'service/auth.go')
-rw-r--r--service/auth.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/service/auth.go b/service/auth.go
index d16fab9..ef701c1 100644
--- a/service/auth.go
+++ b/service/auth.go
@@ -10,6 +10,7 @@ import (
var (
errInvalidSession = errors.New("invalid session")
+ errInvalidAccessToken = errors.New("invalid access token")
errInvalidCSRFToken = errors.New("invalid csrf token")
)
@@ -23,7 +24,7 @@ func NewAuthService(sessionRepo model.SessionRepo, appRepo model.AppRepo, s Serv
return &as{sessionRepo, appRepo, s}
}
-func (s *as) authenticateClient(c *model.Client) (err error) {
+func (s *as) initClient(c *model.Client) (err error) {
if len(c.Ctx.SessionID) < 1 {
return errInvalidSession
}
@@ -46,6 +47,17 @@ func (s *as) authenticateClient(c *model.Client) (err error) {
return nil
}
+func (s *as) authenticateClient(c *model.Client) (err error) {
+ err = s.initClient(c)
+ if err != nil {
+ return
+ }
+ if len(c.Session.AccessToken) < 1 {
+ return errInvalidAccessToken
+ }
+ return nil
+}
+
func checkCSRF(c *model.Client) (err error) {
if c.Ctx.CSRFToken != c.Session.CSRFToken {
return errInvalidCSRFToken
@@ -179,7 +191,7 @@ func (s *as) NewSession(instance string) (redirectUrl string,
func (s *as) Signin(c *model.Client, sessionID string,
code string) (token string, userID string, err error) {
err = s.authenticateClient(c)
- if err != nil {
+ if err != nil && err != errInvalidAccessToken {
return
}