Commit a3678363b6cbd8549bc32fd52d3ddce119f49015
1 parent
1bbcf76f
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Added user not activated exception verification in /login endpoint
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
lib/noosfero/api/session.rb
| @@ -13,7 +13,11 @@ module Noosfero | @@ -13,7 +13,11 @@ module Noosfero | ||
| 13 | # Example Request: | 13 | # Example Request: |
| 14 | # POST http://localhost:3000/api/v1/login?login=adminuser&password=admin | 14 | # POST http://localhost:3000/api/v1/login?login=adminuser&password=admin |
| 15 | post "/login" do | 15 | post "/login" do |
| 16 | - user ||= User.authenticate(params[:login], params[:password], environment) | 16 | + begin |
| 17 | + user ||= User.authenticate(params[:login], params[:password], environment) | ||
| 18 | + rescue NoosferoExceptions::UserNotActivated => e | ||
| 19 | + render_api_error!(e.message, 401) | ||
| 20 | + end | ||
| 17 | 21 | ||
| 18 | return unauthorized! unless user | 22 | return unauthorized! unless user |
| 19 | user.generate_private_token! | 23 | user.generate_private_token! |