Skip to content

Added map to schema object types, fixed expiresAt #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ RestWrite.prototype.transformUser = function() {
'action': 'login',
'authProvider': 'password'
},
restricted: false,
expiresAt: 0
restricted: false
};
var create = new RestWrite(this.config, Auth.master(this.config),
'_Session', null, sessionData);
Expand Down
1 change: 1 addition & 0 deletions Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ function getType(obj) {
case 'string':
case 'number':
return type;
case 'map':
case 'object':
if (!obj) {
return undefined;
Expand Down
9 changes: 9 additions & 0 deletions transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ function transformKeyValue(schema, className, restKey, restValue, options) {
case '_session_token':
key = '_session_token';
break;
case 'expiresAt':
case '_expiresAt':
key = '_expiresAt';
timeField = true;
break;
case '_rperm':
case '_wperm':
return {key: key, value: restValue};
Expand Down Expand Up @@ -642,6 +647,10 @@ function untransformObject(schema, className, mongoObject) {
case '_created_at':
restObject['createdAt'] = Parse._encode(new Date(mongoObject[key])).iso;
break;
case 'expiresAt':
case '_expiresAt':
restObject['expiresAt'] = Parse._encode(new Date(mongoObject[key])).iso;
break;
case '_auth_data_anonymous':
restObject['authData'] = restObject['authData'] || {};
restObject['authData']['anonymous'] = mongoObject[key];
Expand Down
5 changes: 4 additions & 1 deletion users.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function handleLogIn(req) {
user.sessionToken = token;
delete user.password;

var expiresAt = new Date();
expiresAt.setFullYear(expiresAt.getFullYear() + 1);

var sessionData = {
sessionToken: token,
user: {
Expand All @@ -67,7 +70,7 @@ function handleLogIn(req) {
'authProvider': 'password'
},
restricted: false,
expiresAt: 0,
expiresAt: Parse._encode(expiresAt).iso,
installationId: req.info.installationId
};
var create = new RestWrite(req.config, Auth.master(req.config),
Expand Down