Skip to content

Commit f95c232

Browse files
committed
add uid to claims
1 parent c0bb5f0 commit f95c232

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ app.*.map.json
4545
/android/app/profile
4646
/android/app/release
4747

48-
48+
#ignore data dir
49+
data/
4950

5051
# ignore build outputs
5152
bin/

backend/main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"context"
45
"fmt"
56
"log"
67
"net/http"
@@ -65,7 +66,19 @@ func main() {
6566
CookieDuration: time.Hour * 24, // cookie expires in 1 day and will enforce re-login
6667
Issuer: "ferna",
6768
URL: baseUrl,
68-
AvatarStore: avatar.NewLocalFS("/tmp"),
69+
DisableXSRF: true,
70+
ClaimsUpd: token.ClaimsUpdFunc(func(cl token.Claims) token.Claims {
71+
if cl.User.Name == "" {
72+
return cl
73+
}
74+
u, err := database.GetUserByEmail(context.TODO(), cl.User.Name)
75+
if err != nil || u == nil {
76+
return cl
77+
}
78+
cl.User.SetStrAttr("uid", fmt.Sprint(u.ID))
79+
return cl
80+
}),
81+
AvatarStore: avatar.NewLocalFS("/tmp"),
6982
}
7083

7184
// create auth service with providers

0 commit comments

Comments
 (0)