mirror of
https://github.com/janishutz/oidclogin.git
synced 2026-10-08 17:26:20 +02:00
fix: crash on undefined userFunc
This commit is contained in:
1 parent
fa9cc4fbcb
commit
92182271b0
4 files changed
+13
-1
No files matched your search
@@ -102,6 +102,8 @@ func callbackHandler(c *gin.Context) {
|
|||||||
|
|
||||||
if userFunc != nil {
|
if userFunc != nil {
|
||||||
userFunc(claims.Uid, claims.Name, claims.Email)
|
userFunc(claims.Uid, claims.Name, claims.Email)
|
||||||
|
} else {
|
||||||
|
log.Println("[JHID] WARNING: No user function defined")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear session data of oauth related state
|
// Clear session data of oauth related state
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!-- NOTE: You should definitely host this yourself! (and you can adjust the style that way, too!) -->
|
<!-- NOTE: You should definitely host this yourself! (and you can adjust the style that way, too!) -->
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!-- NOTE: You should definitely host this yourself! (and you can adjust the style that way, too!) -->
|
<!-- NOTE: You should definitely host this yourself! (and you can adjust the style that way, too!) -->
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package oidclogin
|
package oidclogin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@@ -15,13 +17,19 @@ func startStubs(r *gin.Engine) {
|
|||||||
func stubsHandler(c *gin.Context) {
|
func stubsHandler(c *gin.Context) {
|
||||||
redir := c.Query("returnTo")
|
redir := c.Query("returnTo")
|
||||||
session := sessions.Default(c)
|
session := sessions.Default(c)
|
||||||
userFunc("stubs", "Stubs User", "example@example.com")
|
if userFunc != nil {
|
||||||
|
userFunc("stubs", "Stubs User", "example@example.com")
|
||||||
|
} else {
|
||||||
|
log.Println("[JHID] WARNING: No user function defined")
|
||||||
|
}
|
||||||
session.Set("jhid_auth", true)
|
session.Set("jhid_auth", true)
|
||||||
session.Set("jhid_uid", "stubs")
|
session.Set("jhid_uid", "stubs")
|
||||||
session.Save()
|
session.Save()
|
||||||
if redir != "" {
|
if redir != "" {
|
||||||
|
log.Println("[JHID] Redirecting to ", redir)
|
||||||
c.Redirect(307, redir)
|
c.Redirect(307, redir)
|
||||||
} else {
|
} else {
|
||||||
|
log.Println("[JHID] Redirecting to ", defaultRedirect, " (default redirect)")
|
||||||
c.Redirect(307, defaultRedirect)
|
c.Redirect(307, defaultRedirect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user