aboutsummaryrefslogtreecommitdiff
path: root/oidc.go
diff options
context:
space:
mode:
Diffstat (limited to 'oidc.go')
-rw-r--r--oidc.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/oidc.go b/oidc.go
index 3e59f8c..31130fb 100644
--- a/oidc.go
+++ b/oidc.go
@@ -246,7 +246,9 @@ func handle_oidc(w http.ResponseWriter, req *http.Request) {
http.SetCookie(w, &cookie)
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
+ var session session_t
var user user_t
+
err = db.FirstOrCreate(&user, user_t{Subject: claims.Subject}).Error
if err != nil {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
@@ -261,14 +263,12 @@ func handle_oidc(w http.ResponseWriter, req *http.Request) {
user.Email = claims.Email
db.Save(&user)
- w.WriteHeader(200)
- w.Write([]byte(fmt.Sprintf(
- "Name: %s\nEmail: %s\nSubject: %s\nCookie: %s\n",
- claims.Name,
- claims.Email,
- claims.Subject,
- cookie_value,
- )))
+ session.User = user
+ session.Cookie = cookie_value
+ err = db.Create(&session).Error
+
+ http.Redirect(w, req, "/", 303)
+
return
}