diff --git a/README.md b/README.md index 7db80e4ca1bf849701dce58a63f09a102cb9f931..579e57ac1f11a2bfa05d581a835f3d6be94ab910 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,7 @@ Things you may want to cover: * Deployment instructions * ... + +login curl + +curl -d '{"user": {"email":"test@surrey.ac.uk", "password":"123456"}}' -H "Content-Type: application/json" -X POST localhost:3000/api/login -i \ No newline at end of file diff --git a/app/controllers/auth_controller.rb b/app/controllers/auth_controller.rb index 831a1b03fa71153988a6f280dace9f22889be1f1..3c3f14c194a3cfd5ad9c93499b08cecdef1ad80a 100644 --- a/app/controllers/auth_controller.rb +++ b/app/controllers/auth_controller.rb @@ -12,4 +12,15 @@ class AuthController < ApplicationController def auth_fail render json: { message: 'Failed to Authenticate User.'} end + + def get_email + puts params + if authenticate_user! + puts "lolol" + puts params + render json: {email: User.find_by(id: params["id"]).email} + else + auth_fail + end + end end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index be254bea3c0c8b2dc17ec19e6b1072bcadcf2f45..1ec2497bb26a99f2459126369f6865d2f46740d4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,7 @@ Rails.application.routes.draw do end post 'auth', to: 'auth#access_check' + post 'auth/email', to: 'auth#get_email' devise_for :users, defaults: { format: :json },