work on user settings

This commit is contained in:
Josh
2018-06-04 15:58:59 -04:00
parent 79949b4aa6
commit d9a95ffc18
22 changed files with 266 additions and 232 deletions

View File

@ -57,9 +57,16 @@ class RoomsController < ApplicationController
def join
opts = default_meeting_options
# If you're unauthenticated, you must enter a name to join the meeting.
if params[@room.invite_path][:join_name]
redirect_to @room.join_path(params[@room.invite_path][:join_name], opts)
if @room.is_running?
# If you're unauthenticated, you must enter a name to join the meeting.
if params[@room.invite_path][:join_name]
redirect_to @room.join_path(params[@room.invite_path][:join_name], opts)
else
redirect_to @room.join_path(current_user, opts)
end
else
# They need to wait until the meeting begins.
end
end

View File

@ -18,7 +18,6 @@ class SessionsController < ApplicationController
else
# Login unsuccessful, display error message.
render :new
end
end

View File

@ -1,11 +1,8 @@
class UsersController < ApplicationController
# GET /signup
def new
@user = User.new
end
before_action :find_user, only: [:edit, :update]
# POST /signup
# POST /users
def create
user = User.new(user_params)
user.provider = "greenlight"
@ -13,18 +10,61 @@ class UsersController < ApplicationController
if user.save
login(user)
else
# Handle error on user creation.
end
end
# GET /settings
def settings
redirect_to root_path unless current_user
# GET /users/:user_uid/edit
def edit
if current_user
redirect_to current_user.room unless @user == current_user
else
redirect_to root_path
end
end
# PATCH /users/:user_uid
def update
# Update account information if passed.
@user.name = user_params[:name] if user_params[:name]
@user.email = user_params[:email] if user_params[:email]
# Verify that the provided password is correct.
if user_params[:password] && @user.authenticate(user_params[:password])
# Verify that the new passwords match.
if user_params[:new_password] == user_params[:password_confirmation]
@user.password = user_params[:new_password]
else
# New passwords don't match.
end
else
# Original password is incorrect, can't update.
end
if @user.save
# Notify the use that their account has been updated.
redirect_to edit_user_path(@user), notice: "Information successfully updated."
else
# Handle validation errors.
render :edit
end
end
private
def find_user
@user = User.find_by(uid: params[:user_uid])
unless @user
# Handle user does not exist.
end
end
def user_params
params.require(:user).permit(:name, :email, :password, :password_confirmation)
params.require(:user).permit(:name, :email, :password, :password_confirmation, :new_password, :provider)
end
end