feat: initial commit
This commit is contained in:
@ -18,7 +18,6 @@ templ LoginPage(vmodel LoginPageVModel) {
|
||||
<nav class="panel is-link" style="min-width: 33%">
|
||||
<p class="panel-heading">
|
||||
<span class="title">Kouiz</span>
|
||||
<span> - Choisissez votre plateforme</span>
|
||||
</p>
|
||||
for _, provider := range vmodel.Providers {
|
||||
<a class="panel-block py-5" href={ templ.URL("/auth/providers/" + provider.ID) } hx-boost="false">
|
||||
|
@ -53,7 +53,7 @@ func LoginPage(vmodel LoginPageVModel) templ.Component {
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"is-flex is-justify-content-center is-align-items-center is-fullheight\"><nav class=\"panel is-link\" style=\"min-width: 33%\"><p class=\"panel-heading\"><span class=\"title\">Kouiz</span> <span> - Choisissez votre plateforme</span></p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"is-flex is-justify-content-center is-align-items-center is-fullheight\"><nav class=\"panel is-link\" style=\"min-width: 33%\"><p class=\"panel-heading\"><span class=\"title\">Kouiz</span></p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@ -96,7 +96,7 @@ func LoginPage(vmodel LoginPageVModel) templ.Component {
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(provider.Label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/http/handler/webui/auth/component/login_page.templ`, Line: 28, Col: 46}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/http/handler/webui/auth/component/login_page.templ`, Line: 27, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
@ -31,13 +31,25 @@ func (h *Handler) handleProviderCallback(w http.ResponseWriter, r *http.Request)
|
||||
slog.DebugContext(ctx, "authenticated user", slog.Any("user", gothUser))
|
||||
|
||||
user := &User{
|
||||
ID: gothUser.UserID,
|
||||
Email: gothUser.Email,
|
||||
Provider: gothUser.Provider,
|
||||
AccessToken: gothUser.AccessToken,
|
||||
IDToken: gothUser.IDToken,
|
||||
Name: gothUser.Name,
|
||||
}
|
||||
|
||||
if user.Email == "" {
|
||||
slog.ErrorContext(r.Context(), "could not authenticate user", slog.Any("error", errors.New("user email missing")))
|
||||
http.Redirect(w, r, "/auth/logout", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
|
||||
if user.Provider == "" {
|
||||
slog.ErrorContext(r.Context(), "could not authenticate user", slog.Any("error", errors.New("user provider missing")))
|
||||
http.Redirect(w, r, "/auth/logout", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
|
||||
rawPreferredUsername, exists := gothUser.RawData["preferred_username"]
|
||||
if exists {
|
||||
if preferredUsername, ok := rawPreferredUsername.(string); ok {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package auth
|
||||
|
||||
type User struct {
|
||||
ID string
|
||||
Email string
|
||||
Provider string
|
||||
AccessToken string
|
||||
IDToken string
|
||||
|
Reference in New Issue
Block a user