Class: CustomerServiceIm::UsersController
Instance Method Summary
collapse
#render_200, #render_401, #render_422, #render_500
Instance Method Details
#login ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'app/controllers/customer_service_im/users_controller.rb', line 4
def login
mp = MiniProgram::Client.new(appid: CustomerServiceIm.appid, app_secret: CustomerServiceIm.app_secret )
result = mp.login(params.require(:code))
if result.failure?
render_500 errors: result.errors
end
open_id = result.data[:openid]
user = User.find_or_create_mp_user(open_id)
render_200 user.as_json.merge({ token: token_user(user), conversation_id: user.conversation_ids.first })
end
|
#update ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/controllers/customer_service_im/users_controller.rb', line 19
def update
user = logged_user
if user.update(user_params)
render_200 result: :ok
else
render_500 errors: user.errors
end
end
|