forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change unconfirmed user login behaviour (mastodon#11375)
Allow access to account settings, 2FA, authorized applications, and account deletions to unconfirmed and pending users, as well as users who had their accounts disabled. Suspended users cannot update their e-mail or password or delete their account. Display account status on account settings page, for example, when an account is frozen, limited, unconfirmed or pending review. After sign up, login users straight away and show a simple page that tells them the status of their account with links to account settings and logout, to reduce onboarding friction and allow users to correct wrongly typed e-mail addresses. Move the final sign-up step of SSO integrations to be the same as above to reduce code duplication.
- Loading branch information
Showing
35 changed files
with
298 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
class Auth::SetupController < ApplicationController | ||
layout 'auth' | ||
|
||
before_action :authenticate_user! | ||
before_action :require_unconfirmed_or_pending! | ||
before_action :set_body_classes | ||
before_action :set_user | ||
|
||
skip_before_action :require_functional! | ||
|
||
def show | ||
flash.now[:notice] = begin | ||
if @user.pending? | ||
I18n.t('devise.registrations.signed_up_but_pending') | ||
else | ||
I18n.t('devise.registrations.signed_up_but_unconfirmed') | ||
end | ||
end | ||
end | ||
|
||
def update | ||
# This allows updating the e-mail without entering a password as is required | ||
# on the account settings page; however, we only allow this for accounts | ||
# that were not confirmed yet | ||
|
||
if @user.update(user_params) | ||
redirect_to auth_setup_path, notice: I18n.t('devise.confirmations.send_instructions') | ||
else | ||
render :show | ||
end | ||
end | ||
|
||
helper_method :missing_email? | ||
|
||
private | ||
|
||
def require_unconfirmed_or_pending! | ||
redirect_to root_path if current_user.confirmed? && current_user.approved? | ||
end | ||
|
||
def set_user | ||
@user = current_user | ||
end | ||
|
||
def set_body_classes | ||
@body_classes = 'lighter' | ||
end | ||
|
||
def user_params | ||
params.require(:user).permit(:email) | ||
end | ||
|
||
def missing_email? | ||
truthy_param?(:missing_email) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%h3= t('auth.status.account_status') | ||
|
||
- if @user.account.suspended? | ||
%span.negative-hint= t('user_mailer.warning.explanation.suspend') | ||
- elsif @user.disabled? | ||
%span.negative-hint= t('user_mailer.warning.explanation.disable') | ||
- elsif @user.account.silenced? | ||
%span.warning-hint= t('user_mailer.warning.explanation.silence') | ||
- elsif !@user.confirmed? | ||
%span.warning-hint= t('auth.status.confirming') | ||
- elsif !@user.approved? | ||
%span.warning-hint= t('auth.status.pending') | ||
- else | ||
%span.positive-hint= t('auth.status.functional') | ||
|
||
%hr.spacer/ |
Oops, something went wrong.