Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .vettedpositions
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
/pkg/auth/handler/webapp/authflowv2/settings_advanced.go:46:30: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_biometric.go:94:30: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_change_password.go:70:30: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_delete_account.go:78:30: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_delete_account.go:80:39: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_delete_account.go:82:34: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_delete_account.go:76:30: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_delete_account.go:78:39: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_delete_account.go:80:34: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_delete_account_success.go:54:30: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_delete_account_success.go:56:34: requestcontext
/pkg/auth/handler/webapp/authflowv2/settings_identity_add_email.go:73:30: requestcontext
Expand Down
2 changes: 1 addition & 1 deletion authui/src/authflowv2/components/otp-input.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
.otp-input__digits-container {
@apply absolute;
@apply inset-0;
@apply flex;
@apply flex justify-center;
@apply items-stretch;
@apply gap-x-[var(--otp-input\_\_spacing)];
@apply pointer-events-none;
Expand Down
7 changes: 6 additions & 1 deletion authui/src/authflowv2/components/widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@
@apply widget-content-item__px--settings;
}

@media (min-width: theme("screens.tablet")) {
.widget-content__alert--settings {
@apply widget-content-item__mx--settings;
}
}
.widget-content__alert--settings {
@apply widget-content-item__mx--settings;
@apply mx-6;
}
}
6 changes: 6 additions & 0 deletions pkg/auth/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ var DependencySet = wire.NewSet(
wire.Bind(new(webapp.SessionMiddlewareSAMLUIInfoResolver), new(*samlsession.UIService)),

wire.Bind(new(webapp.UIInfoResolver), new(*authenticationinfo.UIService)),
wire.Bind(new(handlerwebapp.ControllerUIInfoResolver), new(*authenticationinfo.UIService)),
wire.Bind(new(handlerwebapp.SettingsDeleteAccountSuccessUIInfoResolver), new(*authenticationinfo.UIService)),

wire.Bind(new(handlerwebapp.SelectAccountAuthenticationInfoService), new(*authenticationinfo.StoreRedis)),
wire.Bind(new(handlerwebapp.ControllerAuthenticationInfoService), new(*authenticationinfo.StoreRedis)),
wire.Bind(new(handlerwebappauthflowv2.SelectAccountAuthenticationInfoService), new(*authenticationinfo.StoreRedis)),
wire.Bind(new(handlerwebapp.SettingsDeleteAccountSuccessAuthenticationInfoService), new(*authenticationinfo.StoreRedis)),
wire.Bind(new(handlerwebapp.SettingsDeleteAccountAuthenticationInfoService), new(*authenticationinfo.StoreRedis)),

wire.Bind(new(handlerwebapp.SetupTOTPEndpointsProvider), new(*endpoints.Endpoints)),
wire.Bind(new(handlerwebapp.OAuthEntrypointEndpointsProvider), new(*endpoints.Endpoints)),
wire.Bind(new(handlerwebapp.ConfirmTerminateOtherSessionsEndpointsProvider), new(*endpoints.Endpoints)),
Expand Down Expand Up @@ -189,6 +193,7 @@ var DependencySet = wire.NewSet(
handlerwebapp.DependencySet,
wire.Bind(new(handlerwebapp.AuthflowControllerOAuthClientResolver), new(*oauthclient.Resolver)),
wire.Bind(new(handlerwebapp.AuthflowControllerSessionStore), new(*webapp.SessionStoreRedis)),
wire.Bind(new(handlerwebapp.ControllerSessionStore), new(*webapp.SessionStoreRedis)),
wire.Bind(new(handlerwebapp.SettingsDeleteAccountSessionStore), new(*webapp.SessionStoreRedis)),
wire.Bind(new(handlerwebapp.SettingsAuthenticatorService), new(*authenticatorservice.Service)),
wire.Bind(new(handlerwebapp.SettingsMFAService), new(*mfa.Service)),
Expand All @@ -200,6 +205,7 @@ var DependencySet = wire.NewSet(
wire.Bind(new(handlerwebapp.SettingsProfileEditCustomAttrsService), new(*featurecustomattrs.Service)),
wire.Bind(new(handlerwebapp.SettingsDeleteAccountUserService), new(*facade.UserFacade)),
wire.Bind(new(handlerwebapp.SettingsDeleteAccountOAuthSessionService), new(*oauthsession.StoreRedis)),
wire.Bind(new(handlerwebapp.ControllerOAuthSessionService), new(*oauthsession.StoreRedis)),
wire.Bind(new(handlerwebapp.SettingsEndpointsProvider), new(*endpoints.Endpoints)),
wire.Bind(new(handlerwebapp.SettingsOAuthStateStore), new(*webappoauth.Store)),
wire.Bind(new(handlerwebapp.SettingsAuthorizationService), new(*oauth.AuthorizationService)),
Expand Down
24 changes: 2 additions & 22 deletions pkg/auth/handler/webapp/authflowv2/settings_delete_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import (
handlerwebapp "github.com/authgear/authgear-server/pkg/auth/handler/webapp"
"github.com/authgear/authgear-server/pkg/auth/handler/webapp/viewmodels"
"github.com/authgear/authgear-server/pkg/auth/webapp"
"github.com/authgear/authgear-server/pkg/lib/authn/authenticationinfo"
"github.com/authgear/authgear-server/pkg/lib/config"
"github.com/authgear/authgear-server/pkg/lib/infra/db/appdb"
"github.com/authgear/authgear-server/pkg/lib/oauth/oauthsession"
"github.com/authgear/authgear-server/pkg/lib/session"
"github.com/authgear/authgear-server/pkg/lib/successpage"
"github.com/authgear/authgear-server/pkg/util/clock"
Expand Down Expand Up @@ -110,28 +108,10 @@ func (h *AuthflowV2SettingsDeleteAccountHandler) ServeHTTP(w http.ResponseWriter
return err
}

if webSession != nil && webSession.OAuthSessionID != "" {
if ctrl.IsInSettingsAction(currentSession, webSession) {
// delete account triggered by sdk via settings action
// handle settings action result here

authInfoEntry := authenticationinfo.NewEntry(currentSession.CreateNewAuthenticationInfoByThisSession(), webSession.OAuthSessionID, "")
err := h.AuthenticationInfoService.Save(ctx, authInfoEntry)
if err != nil {
return err
}
webSession.Extra["authentication_info_id"] = authInfoEntry.ID
err = h.Sessions.Update(ctx, webSession)
if err != nil {
return err
}

entry, err := h.OAuthSessions.Get(ctx, webSession.OAuthSessionID)
if err != nil {
return err
}

entry.T.SettingsActionResult = oauthsession.NewSettingsActionResult()
err = h.OAuthSessions.Save(ctx, entry)
err = ctrl.FinishSettingsAction(ctx, currentSession, webSession)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ func (h *AuthflowV2SettingsDeleteAccountSuccessHandler) ServeHTTP(w http.Respons

ctrl.PostAction("", func(ctx context.Context) error {
redirectURI := "/login"
if webSession != nil && webSession.RedirectURI != "" {
settingsActionResult, ok, err := ctrl.GetSettingsActionResult(ctx, webSession)
if err != nil {
return err
}
if ok {
// delete account triggered by sdk via settings action
// redirect to oauth callback
redirectURI = webSession.RedirectURI
if authInfoID, ok := webSession.Extra["authentication_info_id"].(string); ok {
authInfo, err := h.AuthenticationInfoService.Get(ctx, authInfoID)
if err != nil {
return err
}
redirectURI = h.UIInfoResolver.SetAuthenticationInfoInQuery(redirectURI, authInfo)
}
settingsActionResult.WriteResponse(w, r)
return nil
}

result := webapp.Result{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (h *AuthflowV2SettingsIdentityAddEmailHandler) ServeHTTP(w http.ResponseWri
loginID := r.Form.Get("x_login_id")

s := session.GetSession(ctx)
webappSession := webapp.GetSession(ctx)
output, err := h.AccountManagement.StartAddIdentityEmail(ctx, s, &accountmanagement.StartAddIdentityEmailInput{
LoginID: loginID,
LoginIDKey: loginIDKey,
Expand All @@ -102,6 +103,7 @@ func (h *AuthflowV2SettingsIdentityAddEmailHandler) ServeHTTP(w http.ResponseWri
}

var redirectURI *url.URL
navivagationAction := webapp.NavigationActionRedirect
if output.NeedVerification {
redirectURI, err = url.Parse(AuthflowV2RouteSettingsIdentityVerifyEmail)
if err != nil {
Expand All @@ -113,6 +115,14 @@ func (h *AuthflowV2SettingsIdentityAddEmailHandler) ServeHTTP(w http.ResponseWri
q.Set("q_token", output.Token)

redirectURI.RawQuery = q.Encode()
navivagationAction = webapp.NavigationActionAdvance
} else if ctrl.IsInSettingsAction(s, webappSession) {
settingsActionResult, err := ctrl.FinishSettingsActionWithResult(ctx, s, webappSession)
if err != nil {
return err
}
settingsActionResult.WriteResponse(w, r)
return nil
} else {
redirectURI, err = url.Parse(AuthflowV2RouteSettingsIdentityListEmail)
if err != nil {
Expand All @@ -125,7 +135,7 @@ func (h *AuthflowV2SettingsIdentityAddEmailHandler) ServeHTTP(w http.ResponseWri
redirectURI.RawQuery = q.Encode()
}

result := webapp.Result{RedirectURI: redirectURI.String()}
result := webapp.Result{RedirectURI: redirectURI.String(), NavigationAction: navivagationAction}
result.WriteResponse(w, r)
return nil
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (h *AuthflowV2SettingsIdentityAddPhoneHandler) ServeHTTP(w http.ResponseWri
loginID := r.Form.Get("x_login_id")

s := session.GetSession(ctx)
webappSession := webapp.GetSession(ctx)
output, err := h.AccountManagement.StartAddIdentityPhone(ctx, s, &accountmanagement.StartAddIdentityPhoneInput{
Channel: channel,
LoginID: loginID,
Expand All @@ -120,6 +121,13 @@ func (h *AuthflowV2SettingsIdentityAddPhoneHandler) ServeHTTP(w http.ResponseWri
q.Set("q_token", output.Token)

redirectURI.RawQuery = q.Encode()
} else if ctrl.IsInSettingsAction(s, webappSession) {
settingsActionResult, err := ctrl.FinishSettingsActionWithResult(ctx, s, webappSession)
if err != nil {
return err
}
settingsActionResult.WriteResponse(w, r)
return nil
} else {
redirectURI, err = url.Parse(AuthflowV2RouteSettingsIdentityListPhone)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,22 @@ func (h *AuthflowV2SettingsIdentityNewUsernameHandler) ServeHTTP(w http.Response
loginIDKey := r.Form.Get("x_login_id_key")
loginID := r.Form.Get("x_login_id")
resolvedSession := session.GetSession(ctx)
webappSession := webapp.GetSession(ctx)
_, err = h.AccountManagement.AddIdentityUsername(ctx, resolvedSession, &accountmanagement.AddIdentityUsernameInput{
LoginIDKey: loginIDKey,
LoginID: loginID,
})
if err != nil {
return err
}
if ctrl.IsInSettingsAction(resolvedSession, webappSession) {
settingsActionResult, err := ctrl.FinishSettingsActionWithResult(ctx, resolvedSession, webappSession)
if err != nil {
return err
}
settingsActionResult.WriteResponse(w, r)
return nil
}

redirectURI, err := url.Parse(AuthflowV2RouteSettingsIdentityListUsername)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,22 @@ func (h *AuthflowV2SettingsIdentityVerifyEmailHandler) ServeHTTP(w http.Response
code := r.Form.Get("x_code")

s := session.GetSession(ctx)
webappSession := webapp.GetSession(ctx)
_, err = h.AccountManagement.ResumeAddOrUpdateIdentityEmail(ctx, s, tokenString, &accountmanagement.ResumeAddOrUpdateIdentityEmailInput{
LoginIDKey: loginIDKey,
Code: code,
})
if err != nil {
return err
}
if ctrl.IsInSettingsAction(s, webappSession) {
settingsActionResult, err := ctrl.FinishSettingsActionWithResult(ctx, s, webappSession)
if err != nil {
return err
}
settingsActionResult.WriteResponse(w, r)
return nil
}

redirectURI, err := url.Parse(AuthflowV2RouteSettingsIdentityListEmail)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,22 @@ func (h *AuthflowV2SettingsIdentityVerifyPhoneHandler) ServeHTTP(w http.Response
code := r.Form.Get("x_code")

s := session.GetSession(ctx)
webappSession := webapp.GetSession(ctx)
_, err = h.AccountManagement.ResumeAddOrUpdateIdentityPhone(ctx, s, token, &accountmanagement.ResumeAddOrUpdateIdentityPhoneInput{
LoginIDKey: loginIDKey,
Code: code,
})
if err != nil {
return err
}
if ctrl.IsInSettingsAction(s, webappSession) {
settingsActionResult, err := ctrl.FinishSettingsActionWithResult(ctx, s, webappSession)
if err != nil {
return err
}
settingsActionResult.WriteResponse(w, r)
return nil
}

redirectURI, err := url.Parse(AuthflowV2RouteSettingsIdentityListPhone)
if err != nil {
Expand Down
Loading