Class: Doodle::UsersController
Instance Method Summary
collapse
#auth_params, #authenticate, #authenticate_user
Instance Method Details
#create ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'app/controllers/doodle/users_controller.rb', line 21
def create
user = User.new(users_params)
if user.save
render json: user.reload.to_json
else
render json: {error: 'When save keyword'}.to_json
end
end
|
#join ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/doodle/users_controller.rb', line 6
def join
user = User::Analyst.find_by_params(users_params[:login])
channel = params.require(:channel)
if user
if user.has_channels?
user.enter_in_channel(channel)
end
render json: { channel: channel }, status: 200
end
render json: { error: 'User not found' }, status: 404
end
|
#users_params ⇒ Object
30
31
32
|
# File 'app/controllers/doodle/users_controller.rb', line 30
def users_params
params.require(:user).permit(:login, :password, :type)
end
|