Skip to content

Commit a54828d

Browse files
committed
Added facebook signup username and fixed schema parse error for default expired at
1 parent 7ab0537 commit a54828d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

RestWrite.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ RestWrite.prototype.handleFacebookAuthData = function() {
229229
this.className,
230230
{'authData.facebook.id': facebookData.id}, {});
231231
}).then((results) => {
232+
this.storage['authProvider'] = "facebook";
232233
if (results.length > 0) {
233234
if (!this.query) {
234235
// We're signing up, but this user already exists. Short-circuit
@@ -238,7 +239,6 @@ RestWrite.prototype.handleFacebookAuthData = function() {
238239
location: this.location()
239240
};
240241
this.data.objectId = results[0].objectId;
241-
this.data.createdWith = "facebook";
242242
return;
243243
}
244244

@@ -251,6 +251,8 @@ RestWrite.prototype.handleFacebookAuthData = function() {
251251
// We're trying to create a duplicate FB auth. Forbid it
252252
throw new Parse.Error(Parse.Error.ACCOUNT_ALREADY_LINKED,
253253
'this auth is already used');
254+
} else {
255+
this.data.username = rack();
254256
}
255257

256258
// This FB auth does not already exist, so transform it to a
@@ -274,7 +276,6 @@ RestWrite.prototype.transformUser = function() {
274276
var token = 'r:' + rack();
275277
this.storage['token'] = token;
276278
promise = promise.then(() => {
277-
// TODO: Proper createdWith options, pass installationId
278279
var expiresAt = new Date();
279280
expiresAt.setFullYear(expiresAt.getFullYear() + 1);
280281
var sessionData = {
@@ -286,7 +287,7 @@ RestWrite.prototype.transformUser = function() {
286287
},
287288
createdWith: {
288289
'action': 'login',
289-
'authProvider': this.data.createdWith || 'password'
290+
'authProvider': this.storage['authProvider'] || 'password'
290291
},
291292
restricted: false,
292293
installationId: this.data.installationId,
@@ -413,6 +414,8 @@ RestWrite.prototype.handleSession = function() {
413414

414415
if (!this.query && !this.auth.isMaster) {
415416
var token = 'r:' + rack();
417+
var expiresAt = new Date();
418+
expiresAt.setFullYear(expiresAt.getFullYear() + 1);
416419
var sessionData = {
417420
sessionToken: token,
418421
user: {
@@ -424,7 +427,7 @@ RestWrite.prototype.handleSession = function() {
424427
'action': 'create'
425428
},
426429
restricted: true,
427-
expiresAt: 0
430+
expiresAt: Parse._encode(expiresAt)
428431
};
429432
for (var key in this.data) {
430433
if (key == 'objectId') {

0 commit comments

Comments
 (0)