From 2fa916e2f40a8ebb691308fbb08a26f0eb0ffd59 Mon Sep 17 00:00:00 2001
From: rt00492 <rt00492@surrey.ac.uk>
Date: Tue, 26 Apr 2022 23:23:44 +0100
Subject: [PATCH] Correcting mispellings and adjusting get_email

---
 app/controllers/auth_controller.rb | 10 +++++++---
 lib/my_failure_app.rb              |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/app/controllers/auth_controller.rb b/app/controllers/auth_controller.rb
index 3c3f14c..a7ab6c6 100644
--- a/app/controllers/auth_controller.rb
+++ b/app/controllers/auth_controller.rb
@@ -15,10 +15,14 @@ class AuthController < ApplicationController
 
     def get_email
         puts params
+        ids = params["auth"]["ids"]
+        puts ids
         if authenticate_user!
-            puts "lolol"
-            puts params
-            render json: {email: User.find_by(id: params["id"]).email}
+            emails = []
+            ids.each do |i|
+                emails.push(User.find_by(id: i).email)
+            end 
+            render json: { emails: emails }
         else
             auth_fail
         end
diff --git a/lib/my_failure_app.rb b/lib/my_failure_app.rb
index 2307959..dad9278 100644
--- a/lib/my_failure_app.rb
+++ b/lib/my_failure_app.rb
@@ -6,6 +6,6 @@ class MyFailureApp < Devise::FailureApp
     def json_failure
         self.status = 401
         self.content_type = 'application/json'
-        self.response_body = "{'error' : 'authenticaition error'}".to_json
+        self.response_body = "{'error' : 'authentication error'}".to_json
     end
 end
-- 
GitLab