mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-15 18:25:13 +00:00
feat(login): show profile (#485)
* profile data * fix scripts * fix image paths * feat: show profile (with image) when possible * fix profile image width
This commit is contained in:
@@ -3,11 +3,12 @@ package handler
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gorilla/csrf"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"path"
|
||||
|
||||
"github.com/gorilla/csrf"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/http/middleware"
|
||||
"github.com/caos/zitadel/internal/auth_request/model"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
@@ -185,6 +186,13 @@ func (l *Login) renderInternalError(w http.ResponseWriter, r *http.Request, auth
|
||||
l.renderer.RenderTemplate(w, r, l.renderer.Templates[tmplError], data, nil)
|
||||
}
|
||||
|
||||
func (l *Login) getUserData(r *http.Request, authReq *model.AuthRequest, title string, errType, errMessage string) userData {
|
||||
return userData{
|
||||
baseData: l.getBaseData(r, authReq, title, errType, errMessage),
|
||||
profileData: l.getProfileData(authReq),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Login) getBaseData(r *http.Request, authReq *model.AuthRequest, title string, errType, errMessage string) baseData {
|
||||
return baseData{
|
||||
errorData: errorData{
|
||||
@@ -201,6 +209,18 @@ func (l *Login) getBaseData(r *http.Request, authReq *model.AuthRequest, title s
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Login) getProfileData(authReq *model.AuthRequest) profileData {
|
||||
var loginName, displayName string
|
||||
if authReq != nil {
|
||||
loginName = authReq.LoginName
|
||||
displayName = authReq.DisplayName
|
||||
}
|
||||
return profileData{
|
||||
LoginName: loginName,
|
||||
DisplayName: displayName,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Login) getErrorMessage(r *http.Request, err error) (errMsg string) {
|
||||
caosErr := new(caos_errs.CaosError)
|
||||
if errors.As(err, &caosErr) {
|
||||
@@ -257,15 +277,20 @@ type errorData struct {
|
||||
|
||||
type userData struct {
|
||||
baseData
|
||||
LoginName string
|
||||
profileData
|
||||
PasswordChecked string
|
||||
MfaProviders []model.MfaType
|
||||
SelectedMfaProvider model.MfaType
|
||||
}
|
||||
|
||||
type profileData struct {
|
||||
LoginName string
|
||||
DisplayName string
|
||||
}
|
||||
|
||||
type passwordData struct {
|
||||
baseData
|
||||
LoginName string
|
||||
profileData
|
||||
PasswordPolicyDescription string
|
||||
MinLength uint64
|
||||
HasUppercase string
|
||||
@@ -281,22 +306,22 @@ type userSelectionData struct {
|
||||
|
||||
type mfaData struct {
|
||||
baseData
|
||||
LoginName string
|
||||
profileData
|
||||
MfaProviders []model.MfaType
|
||||
MfaRequired bool
|
||||
}
|
||||
|
||||
type mfaVerifyData struct {
|
||||
baseData
|
||||
LoginName string
|
||||
MfaType model.MfaType
|
||||
profileData
|
||||
MfaType model.MfaType
|
||||
otpData
|
||||
}
|
||||
|
||||
type mfaDoneData struct {
|
||||
baseData
|
||||
LoginName string
|
||||
MfaType model.MfaType
|
||||
profileData
|
||||
MfaType model.MfaType
|
||||
}
|
||||
|
||||
type otpData struct {
|
||||
|
||||
Reference in New Issue
Block a user