Skip to content

Instantly share code, notes, and snippets.

@0xMH
Created May 2, 2018 17:32
Show Gist options
  • Save 0xMH/16714bbae4888e0d0a63c09d68b95fb5 to your computer and use it in GitHub Desktop.
Save 0xMH/16714bbae4888e0d0a63c09d68b95fb5 to your computer and use it in GitHub Desktop.
/**
* Authentication
* @namespace thinkster.authentication.services
* Make a file in static/javascripts/authentication/services/ called authentication.service.js
*/
(function () {
'use strict';
angular
.module('thinkster.authentication.services')
.factory('Authentication', Authentication);
Authentication.$inject = ['$cookies', '$http'];
/**
* @namespace Authentication
* @returns {Factory}
*/
function Authentication($cookies, $http) {
/**
* @name Authentication
* @desc The Factory to be returned
*/
var Authentication = {
register: register
};
return Authentication;
////////////////////
/**
* @name register
* @desc Try to register a new user
* @param {string} username The username entered by the user
* @param {string} password The password entered by the user
* @param {string} email The email entered by the user
* @returns {Promise}
* @memberOf thinkster.authentication.services.Authentication
*/
function register(email, password, username) {
return $http.post('/api/v1/accounts/', {
username: username,
password: password,
email: email
});
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment