Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LoginHelper{
- /**
- *
- * Function that logs a user into the FMO system
- * Accepts a success and failure function to handle when a login request has been done.
- */
- login(email, password, success, failure){
- // Encode the params
- var params = 'email=' + email + '&password=' + password;
- // if there is a device id also pass that
- if(window.localStorage.getItem('deviceToken') !== null){
- params += '&deviceToken=' + window.localStorage.getItem('deviceToken') + '&deviceType=' + encodeURIComponent(device.platform) + '&deviceUUID=' + encodeURIComponent(device.uuid) + '&deviceOSVersion=' + encodeURIComponent(device.version);
- }
- // Do Ajax request to check the users details
- var ajax = new XMLHttpRequest();
- // Get the Menu. This is Where the products get built into the page
- ajax.onreadystatechange=function(){
- if (ajax.readyState==4 && ajax.status==200){
- var user = JSON.parse(ajax.responseText);
- console.log(user);
- if(user == false){
- failure('Shit Went South');
- }
- success(user);
- }
- }
- // Prepare the post login
- ajax.open("POST", apiUrl + 'user/login', true);
- //Send the proper header information along with the request
- ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- ajax.send(params);
- },
- forgotPassword(email){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement