forked from External/greenlight
finish settings and public recordings
This commit is contained in:
@ -42,6 +42,10 @@ class UsersController < ApplicationController
|
||||
# Update account information if passed.
|
||||
@user.name = user_params[:name] if user_params[:name]
|
||||
@user.email = user_params[:email] if user_params[:email]
|
||||
@user.image = user_params[:image] if user_params[:image]
|
||||
|
||||
# Custom errors not generated by validations.
|
||||
errors = {}
|
||||
|
||||
# Verify that the provided password is correct.
|
||||
if user_params[:password] && @user.authenticate(user_params[:password])
|
||||
@ -50,17 +54,20 @@ class UsersController < ApplicationController
|
||||
@user.password = user_params[:new_password]
|
||||
else
|
||||
# New passwords don't match.
|
||||
|
||||
errors[:password_confirmation] = "'s don't match"
|
||||
end
|
||||
else
|
||||
# Original password is incorrect, can't update.
|
||||
|
||||
errors[:password] = "is incorrect"
|
||||
end
|
||||
|
||||
if @user.save
|
||||
# Notify the use that their account has been updated.
|
||||
redirect_to edit_user_path(@user), notice: "Information successfully updated."
|
||||
else
|
||||
# Append custom errors.
|
||||
errors.each do |k, v| @user.errors.add(k, v) end
|
||||
|
||||
# Handle validation errors.
|
||||
render :edit
|
||||
end
|
||||
@ -82,6 +89,6 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:name, :email, :password, :password_confirmation, :new_password, :provider)
|
||||
params.require(:user).permit(:name, :email, :image, :password, :password_confirmation, :new_password, :provider)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user