Skip to content
Snippets Groups Projects
Commit 189c0d27 authored by Treadway, Ross T (UG - Computer Science)'s avatar Treadway, Ross T (UG - Computer Science)
Browse files

added retriving emails

parent 9b45f922
No related branches found
No related tags found
1 merge request!2added retriving emails
...@@ -22,3 +22,7 @@ Things you may want to cover: ...@@ -22,3 +22,7 @@ Things you may want to cover:
* Deployment instructions * 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
...@@ -12,4 +12,15 @@ class AuthController < ApplicationController ...@@ -12,4 +12,15 @@ class AuthController < ApplicationController
def auth_fail def auth_fail
render json: { message: 'Failed to Authenticate User.'} render json: { message: 'Failed to Authenticate User.'}
end 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 end
\ No newline at end of file
...@@ -5,6 +5,7 @@ Rails.application.routes.draw do ...@@ -5,6 +5,7 @@ Rails.application.routes.draw do
end end
post 'auth', to: 'auth#access_check' post 'auth', to: 'auth#access_check'
post 'auth/email', to: 'auth#get_email'
devise_for :users, devise_for :users,
defaults: { format: :json }, defaults: { format: :json },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment