Skip to content

Commit

Permalink
Use rest.update to guaranteed proper beforeSave and liveQuery calls
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed May 24, 2017
1 parent c585fc8 commit a87f5e1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import rest from '../rest';
import Parse from 'parse/node';

var RestQuery = require('../RestQuery');
var RestWrite = require('../RestWrite');
var Auth = require('../Auth');

export class UserController extends AdaptableController {
Expand Down Expand Up @@ -60,13 +59,13 @@ export class UserController extends AdaptableController {

updateFields._email_verify_token_expires_at = {__op: 'Delete'};
}

const masterAuth = Auth.master(this.config);
var checkIfAlreadyVerified = new RestQuery(this.config, Auth.master(this.config), '_User', {username: username, emailVerified: true});
return checkIfAlreadyVerified.execute().then(result => {
if (result.results.length) {
return Promise.resolve(result.results.length[0]);
}
return new RestWrite(this.config, Auth.master(this.config), '_User', query, updateFields).execute();
return rest.update(this.config, masterAuth, '_User', query, updateFields);
});
}

Expand Down

0 comments on commit a87f5e1

Please sign in to comment.