Skip to content

Commit ecd218f

Browse files
authored
Merge pull request #69 from FullstackAcademy/removeSessionIdFromClient
Remove session id from client
2 parents c051b37 + 5640ab6 commit ecd218f

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

generated/browser/js/fsa/fsa-pre-built.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
app.service('AuthService', function ($http, Session, $rootScope, AUTH_EVENTS, $q) {
5252

5353
function onSuccessfulLogin(response) {
54-
var data = response.data;
55-
Session.create(data.id, data.user);
54+
var user = response.data.user;
55+
Session.create(user);
5656
$rootScope.$broadcast(AUTH_EVENTS.loginSuccess);
57-
return data.user;
57+
return user;
5858
}
5959

6060
// Uses the session factory to see if an
@@ -115,16 +115,13 @@
115115
self.destroy();
116116
});
117117

118-
this.id = null;
119118
this.user = null;
120119

121120
this.create = function (sessionId, user) {
122-
this.id = sessionId;
123121
this.user = user;
124122
};
125123

126124
this.destroy = function () {
127-
this.id = null;
128125
this.user = null;
129126
};
130127

generated/tests/browser/fsa-prebuilt/auth-service-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('AuthService', function () {
2626
describe('isAuthenicated', function () {
2727

2828
it('should return true if a Session exists', function () {
29-
Session.create('testID', {email: '[email protected]'});
29+
Session.create({email: '[email protected]'});
3030
expect(AuthService.isAuthenticated()).to.be.ok;
3131
});
3232

@@ -41,7 +41,7 @@ describe('AuthService', function () {
4141

4242
it('should return the user from the Session if already authenticated', function (done) {
4343
var x = {};
44-
Session.create('testID', x);
44+
Session.create(x);
4545
AuthService.getLoggedInUser().then(function (user) {
4646
expect(user).to.be.equal(x);
4747
done();
@@ -257,7 +257,7 @@ describe('AuthService', function () {
257257

258258
it('should destroy the session', function (done) {
259259

260-
Session.create('testID', { email: '[email protected]' });
260+
Session.create({ email: '[email protected]' });
261261

262262
AuthService.logout().then(function () {
263263
expect(Session.user).to.be.equal(null);
@@ -285,4 +285,4 @@ describe('AuthService', function () {
285285

286286
});
287287

288-
});
288+
});

0 commit comments

Comments
 (0)