better flash + error messages

We had a confused meta thread today when a screenshot of a user deleting their
account was thought to be a ban.
This commit is contained in:
Peter Bhat Harkins 2020-10-13 20:55:19 -05:00
parent df5b1e0487
commit 21524de9ed
4 changed files with 19 additions and 4 deletions

View File

@ -108,7 +108,7 @@ class LoginController < ApplicationController
@found_user = User.where("email = ? OR username = ?", params[:email], params[:email]).first
if !@found_user
flash.now[:error] = "Invalid e-mail address or username."
flash.now[:error] = "Unknown e-mail address or username."
return forgot_password
end

View File

@ -15,16 +15,18 @@ class SettingsController < ApplicationController
return redirect_to settings_path
end
unless @user.try(:authenticate, params[:user][:password].to_s)
flash[:error] = "Your password could not be verified."
flash[:error] = "Given password doesn't match account."
return redirect_to settings_path
end
@user.delete!
disown_text = ""
if params[:user][:disown].present?
disown_text = " and disowned your stories and comments."
InactiveUser.disown_all_by_author! @user
end
reset_session
flash[:success] = "Your account has been deleted."
flash[:success] = "You have deleted your account your account#{disown_text}. Bye."
return redirect_to "/"
end

View File

@ -6,7 +6,12 @@ class UsersController < ApplicationController
before_action :only_user_or_moderator, only: [:standing]
def show
@showing_user = User.where(:username => params[:username]).first!
@showing_user = User.where(:username => params[:username]).first
if @showing_user.nil?
return render action: :not_found, status: 404
end
@title = "User #{@showing_user.username}"
if @user.try(:is_moderator?)

View File

@ -0,0 +1,8 @@
<div class="box wide">
<div class="legend">User not found</div>
<p>
If this user used to exist, they changed their username.
Check the <a href="/moderations?moderator=%28Users%29&what%5Busers%5D=users">moderation log</a>.
</p>
</div>