Skip to content

Commit 55eb1d5

Browse files
committed
[Finishes #173176790] Finish modifying Social Authentication functionality to redirect to client
1 parent 58704f5 commit 55eb1d5

File tree

3 files changed

+7
-29
lines changed

3 files changed

+7
-29
lines changed

server/controllers/authController.js

+1-17
Original file line numberDiff line numberDiff line change
@@ -172,23 +172,7 @@ class AuthController {
172172
isVerified
173173
});
174174

175-
res.status(200).json({
176-
status: 200,
177-
message: `User successfully signed in with ${authType}`,
178-
data: {
179-
token,
180-
user: {
181-
username,
182-
firstname,
183-
lastname,
184-
email,
185-
role,
186-
lineManager,
187-
isVerified,
188-
authType
189-
}
190-
}
191-
});
175+
res.redirect(`https://champs-frontend.herokuapp.com/home?${token}`);
192176
} catch (error) {
193177
return res.status(500).json({
194178
status: 500,

server/middleware/user.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class User {
135135
*/
136136
static async verifyGoogleSignIn(req, res, next) {
137137
try {
138-
passport.authenticate('google', { failureRedirect: '/google', session: false }, (err, user) => {
138+
passport.authenticate('google', { failureRedirect: 'https://champs-frontend.herokuapp.com/signin', session: false }, (err, user) => {
139139
if (err) { return next(err); }
140140
req.user = user;
141141
return next();
@@ -154,7 +154,7 @@ class User {
154154
*/
155155
static async verifyFacebookSignIn(req, res, next) {
156156
try {
157-
passport.authenticate('facebook', { failureRedirect: '/facebook', session: false }, (err, user) => {
157+
passport.authenticate('facebook', { failureRedirect: 'https://champs-frontend.herokuapp.com/signin', session: false }, (err, user) => {
158158
if (err) { return next(err); }
159159
req.user = user;
160160
return next();

server/tests/oauth.test.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,9 @@ describe('Google Social Sign In Test', () => {
6262
it('should successfully sign in the user with Google', (done) => {
6363
request(app).get('/api/v1/auth/google/return')
6464
.send(mockData[2])
65-
.expect(200)
65+
.expect(302)
6666
.end((err, res) => {
67-
expect(res).to.have.status(200);
68-
expect(res.body).to.be.a('object');
69-
expect(res.body).to.have.property('status');
70-
expect(res.body).to.have.property('message');
67+
expect(res).to.have.status(302);
7168
done();
7269
});
7370
});
@@ -87,12 +84,9 @@ describe('Facebook Social Sign In Test', () => {
8784
it('should successfully sign in the user with Facebook', (done) => {
8885
request(app).get('/api/v1/auth/facebook/return')
8986
.send(mockData[2])
90-
.expect(200)
87+
.expect(302)
9188
.end((err, res) => {
92-
expect(res).to.have.status(200);
93-
expect(res.body).to.be.a('object');
94-
expect(res.body).to.have.property('status');
95-
expect(res.body).to.have.property('message');
89+
expect(res).to.have.status(302);
9690
done();
9791
});
9892
});

0 commit comments

Comments
 (0)