0.2.0 • Published 8 years ago

candf-auth v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

Installation

$ npm install candf-auth

Usage

Service used to create pass and login user from qrcode.

Add these lines into your PROJECT/app/scripts/services/index.js

var authService = require('candf-auth');
app.factory('AuthService', ['$http', '$q', authService]);

Then, call it in your controllers to :

Create pass

AuthService.createPass(user).then(function (data) {
   // popup closing / confirm / redirection to state
}

Example :

AuthService.createPass(user).then(function (data) {
       
 $('#createpass').closest(".wrapper").removeClass("showKeyboard");
 $('.ui-keyboard').hide();

 confirm = ngDialog.open({
   template: 'popinconfirmpass',
   className: 'ngdialog-theme-inscription',
   showClose : false,
   scope : $scope,
   closeByDocument : false
 });
 $timeout(function() {
   confirm.close();
   $state.go("square");
 }, 3000);
}, function () {
 $rootScope.popin = ngDialog.open({
   template: 'popinerrorinscription',
   className: 'ngdialog-theme-inscription',
   showClose : false,
   scope : $scope
 });
});

Login from QR Code

AuthService.login(qrcode).then(function() {
   // popup closing / confirm / redirection to state
}

Example :

AuthService.login(qrcode).then(function() {
 $('.ui-keyboard').remove();

 if (AuthService.userRole == AuthService.CLIENT) {
   app.start();
   $state.go(nextState);
 } else if (AuthService.userRole == AuthService.PROSPECT) {
   app.start(); 
   $state.go(nextState);
 } else {
   app.error();
 }
}).catch(function(err) {
 console.log(err);
 app.error();
});

Access to user's properties

AuthService.user 
AuthService.userId 
AuthService.userRole 
AuthService.bienvenue
AuthService.qrcode 
AuthService.popinEventDisplayed 
AuthService.showPopinMessage 
AuthService.showPopinNextMeeting
0.2.0

8 years ago

0.1.0

8 years ago