Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@ angular.module('myModule', ['Devise']).
// Pass false to disable the namespace altogether.
AuthProvider.resourceName('customer');

// Also you can change host URL for backend calls
// (for example if it's on another server than your angular app)
AuthProvider.baseUrl('http://localhost:3000');

// Customize user parsing
// NOTE: **MUST** return a truth-y expression
AuthProvider.parse(function(response) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AngularDevise",
"version": "1.2.2",
"version": "1.2.3",
"description": "A small AngularJS Service to interact with Devise Authentication.",
"main": "lib/devise.js",
"scripts": {
Expand Down
14 changes: 14 additions & 0 deletions src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ devise.provider('Auth', function AuthProvider() {
resetPassword: 'PUT'
};

/**
* The default host URL.
*/
var baseUrl = '';

/**
* Default devise resource_name is 'user', can be set to any string.
* If it's falsey, it will not namespace the data.
Expand Down Expand Up @@ -83,6 +88,15 @@ devise.provider('Auth', function AuthProvider() {
configure.call(this, methods, 'Method');
configure.call(this, paths, 'Path');

// The baseUrl config function
this.baseUrl = function(value) {
if (value === undefined) {
return baseUrl;
}
baseUrl = value;
return this;
};

// The resourceName config function
this.resourceName = function(value) {
if (value === undefined) {
Expand Down
8 changes: 8 additions & 0 deletions test/spec/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ describe('Provider: Devise.Auth', function () {
expect(callCount).toBe(1);
});

it('.baseUrl', function() {
var baseUrl = 'http://localhost:3000';
initService(function() {
AuthProvider.baseUrl(baseUrl);
});
expect(AuthProvider.baseUrl()).toEqual(baseUrl);
});

describe('.resourceName', function() {
var credentials = {test: 'test'};
afterEach(function() {
Expand Down