fix auth url spec

This commit is contained in:
Umputun
2018-06-27 19:32:01 -05:00
parent 3e5f6ea6ff
commit 822ef7df34
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -313,7 +313,7 @@ Also script can uses `url` property from `remark_config` object, or `window.loca
### Authorization
* `GET /auth/{provider}/login?from=http://url&session=1` - perform "social" login with one of supported providers and redirect to `url`. Presence of `session` (any non-zero value) change the default cookie expiration and makes them session-only.
* `GET /auth/{provider}/login?from=http://url&site=site_id&session=1` - perform "social" login with one of supported providers and redirect to `url`. Presence of `session` (any non-zero value) change the default cookie expiration and makes them session-only.
* `GET /auth/logout` - logout
```go
+4 -3
View File
@@ -107,7 +107,7 @@ func (p Provider) loginHandler(w http.ResponseWriter, r *http.Request) {
// return login url
loginURL := p.conf.AuthCodeURL(state)
log.Printf("[DEBUG] login url %s", loginURL)
log.Printf("[DEBUG] login url %s, claims=%+v", loginURL, claims)
http.Redirect(w, r, loginURL, http.StatusFound)
}
@@ -164,7 +164,7 @@ func (p Provider) authHandler(w http.ResponseWriter, r *http.Request) {
u = p.setPermissions(u, oauthClaims.SiteID)
u = p.setAvatar(u)
authClaims := &CustomClaims{
claims := &CustomClaims{
User: &u,
StandardClaims: jwt.StandardClaims{
Issuer: "remark42",
@@ -173,7 +173,7 @@ func (p Provider) authHandler(w http.ResponseWriter, r *http.Request) {
SessionOnly: oauthClaims.SessionOnly,
}
if err = p.JwtService.Set(w, authClaims, oauthClaims.SessionOnly); err != nil {
if err = p.JwtService.Set(w, claims, oauthClaims.SessionOnly); err != nil {
rest.SendErrorJSON(w, r, http.StatusInternalServerError, err, "failed to save user info")
return
}
@@ -205,6 +205,7 @@ func (p Provider) setPermissions(u store.User, siteID string) store.User {
u.Admin = p.PermissionChecker.IsAdmin(u.ID)
u.Verified = p.PermissionChecker.IsVerified(siteID, u.ID)
u.Blocked = p.PermissionChecker.IsBlocked(siteID, u.ID)
log.Printf("[DEBUG] set permissions for user %s, site %s - %+v", u.ID, siteID, u)
return u
}