Skip to content

Commit

Permalink
Debut rebranchement fc front
Browse files Browse the repository at this point in the history
  • Loading branch information
Flightan committed Sep 14, 2015
1 parent e7da525 commit b40f558
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
37 changes: 37 additions & 0 deletions client/components/connection/connection.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@ angular.module('boursesApp').directive('connection', function($http, $window, $l
restrict: 'EA',
link: function(scope) {

// Feature-flipping fc
scope.enableFranceConnect = false;

function tryFcLogin() {
$http
.get('/api/connection/fc')
.then(
function(result) {
scope.fc = result.data.response;
if (typeof scope.fc === 'string' && scope.fc.startsWith('{')) {
scope.fc = JSON.parse(scope.fc);
}

setStatus('success');
store.set('fc_' + scope.connectionId, scope.fc);
},

function() {
store.set('fc_' + scope.connectionId, null);
return null;
});
}

function fcLogout() {
$http
.get('/oauth/fc/logout')
.then(function() {
setStatus('pending');
store.set('fc_' + scope.connectionId, null);
});
}

scope.svair = store.get('svair_' + scope.connectionId);
scope.credentials = scope.svair ? _.cloneDeep(scope.svair.credentials) : {};
var oldStatus = scope.status = store.get('status_' + scope.connectionId);
Expand Down Expand Up @@ -116,6 +148,11 @@ angular.module('boursesApp').directive('connection', function($http, $window, $l
store.set('status_' + scope.connectionId, status);
}

if (scope.enableFranceConnect) {
tryFcLogin();
scope.fcLogout = fcLogout;
}

scope.edit = edit;
scope.validateSvair = validateSvair;
scope.cancelCredentials = cancelCredentials;
Expand Down
16 changes: 16 additions & 0 deletions client/components/connection/connection.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
<div ng-if="status !== 'success'">
<div class="choices-connect">
<div ng-if="enableFranceConnect">
<div class="connect-fc">
<h2 ng-if="connectionId === 'demandeur'">Vous avez un compte impots.gouv.fr</h2>
<h2 ng-if="connectionId !== 'demandeur'">Connection avec son compte impots.gouv.fr</h2>
<div class="connect-fc-img">
<a href="/oauth/fc" ng-click="saveAndConnect($event)" target="self" title="Se connecter avec son compte impots.gouv.fr">
<img src="assets/images/franceconnect.png" alt="Se connecter avec son compte impots.gouv.fr">
<span>Se connecter avec son compte impots.gouv.fr</span>
</a>
</div>
</div>
</div>
<div class="connect-svair">
<div ng-if="enableFranceConnect">
<h2 ng-if="connectionId === 'demandeur'">Vous n'avez pas de compte impots.gouv.fr</h2>
<h2 ng-if="connectionId !== 'demandeur'">L'autre parent ne possède pas de compte impots.gouv.fr</h2>
</div>
<ng-form class="svair-form" name="svairForm" ng-submit="validateSvair(svairForm)" novalidate>
<div class="form-group required" ng-class="{'has-error': svairForm.numeroFiscal.$invalid && svairForm.$submitted}">

Expand Down

0 comments on commit b40f558

Please sign in to comment.