summaryrefslogtreecommitdiff
path: root/lib/api/session.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2012-09-20 17:44:44 +0300
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2012-09-20 17:45:07 +0300
commit9aafe77e708174aac697a8dcafc99b90e96be36e (patch)
treecb22fddcf3feeefb381a3ded1407ef11767395b5 /lib/api/session.rb
parent37817cc31d890f1e79b31ae3d625fbace672451e (diff)
downloadgitlab-ce-9aafe77e708174aac697a8dcafc99b90e96be36e.tar.gz
I want be able to get token via api. Used for mobile applications
Diffstat (limited to 'lib/api/session.rb')
-rw-r--r--lib/api/session.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/api/session.rb b/lib/api/session.rb
new file mode 100644
index 00000000000..5bcdf93abe9
--- /dev/null
+++ b/lib/api/session.rb
@@ -0,0 +1,21 @@
+module Gitlab
+ # Users API
+ class Session < Grape::API
+ # Login to get token
+ #
+ # Example Request:
+ # POST /session
+ post "/session" do
+ resource = User.find_for_database_authentication(email: params[:email])
+
+ return forbidden! unless resource
+
+ if resource.valid_password?(params[:password])
+ present resource, with: Entities::UserLogin
+ else
+ forbidden!
+ end
+ end
+ end
+end
+