<commit_before>'use strict';

/* 
 * API Routes for Auth
 * 
 * API calls related to authentication.
 */

angular.module('apiRoutes.auth', [])
.factory('ApiRoutesAuth', ['ApiService', function (API) {
        
    var api = {};

    api.postLogin = function(credentials) {
        if(!credentials.password || !credentials.email) {
            return API.reject('Invalid credentials please verify your information and try again.');
        }
        
        var fd = new FormData();
        fd.append('email', credentials.email);
        fd.append('password', <PASSWORD>);
        fd.append('remember', credentials.remember || false);

        return API.post('auth/login/', fd, 'System unable to login.');
    };

    api.postLogout = function() {                
        return API.post('auth/logout/', new FormData(), 'System unable to logout.');
    };

    api.postForgotPasswordEmail = function(email) {
        var fd = new FormData();
        fd.append('email', email);

        return API.post('auth/password-reset/', fd, 'Error sending password reset email.');
    };

    api.postValidatePasswordResetToken = function(token) {
        if(!token) {
            return API.reject('Invalid password reset token.');
        }

        var fd = new FormData();
        fd.append('token', token);

        return API.post('auth/validate-token/', fd, 'Error validating token.');
    };

    api.updatePassword = function(user) {
        if(!user.id || !user.email || !user.token || !user.password || user.password <= 0) {<commit_msg>Logout needs to specify the key to logout.<commit_after>'use strict';

/* 
 * API Routes for Auth
 * 
 * API calls related to authentication.
 */

angular.module('apiRoutes.auth', [])
.factory('ApiRoutesAuth', ['ApiService', function (API) {
        
    var api = {};

    api.postLogin = function(credentials) {
        if(!credentials.password || !credentials.email) {
            return API.reject('Invalid credentials please verify your information and try again.');
        }
        
        var fd = new FormData();
        fd.append('email', credentials.email);
        fd.append('password', <PASSWORD>);
        fd.append('remember', credentials.remember || false);
        if(credentials.logout) { fd.append('logout', credentials.logout); };

        return API.post('auth/login/', fd, 'System unable to login.');
    };

    api.postLogout = function(logout) {
        var fd = new FormData();
        fd.append('logout', logout);
        
        return API.post('auth/logout/', fd, 'System unable to logout.');
    };

    api.postForgotPasswordEmail = function(email) {
        var fd = new FormData();
        fd.append('email', email);

        return API.post('auth/password-reset/', fd, 'Error sending password reset email.');
    };

    api.postValidatePasswordResetToken = function(token) {
        if(!token) {
            return API.reject('Invalid password reset token.');
        }

        var fd = new FormData();
        fd.append('token', token);

        return API.post('auth/validate-token/', fd, 'Error validating token.');
    };

    api.updatePassword = function(user) {
        if(!user.id || !user.email || !user.token || !user.password || user.password <= 0) {
{'fraction_non_alphanumeric': 0.15075687364843993, 'fraction_numerical': 0.0006178560395427865, 'mean_word_length': 2.5233949945593035, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3304138', 'n_tokens_mistral': 921, 'n_tokens_neox': 904, 'n_words': 223}