I'm currently setting up a login feature using angular.js and devise.
Below is the code for my form:
<form ng-submit="submitLogin(loginForm)" role="form" ng-init="loginForm = {}">
<div class="form-group">
<label for="email">Email</label>
<input type="email" name="email" id="email" ng-model="loginForm.email" required="required" class="form-control"> </div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" id="password" ng-model="loginForm.password" required="required" class="form-control"> </div>
<button type="submit" class="btn btn-primary btn-lg">Sign in</button>
</form>
The form always sends data via POST
to /api/auth/sign_in
. However, the path of my API also includes a version number.
Therefore, /api/v1/auth/sign_in
would be valid but not /api/auth/sign_in
.
Is there a way to modify the form action to include the API version as well?
Update: Important Angular Information
angular
.module('AngularRails', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'templates',
'ng-token-auth'
]).config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/app/sign_in', {
templateUrl: 'user_sessions/new.html',
controller: 'UserSessionsCtrl'
})
.otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
The function submitLogin
originates from here. Is it possible to customize or override this function from ng-token-auth (A token-based authentication module for angular.js)?