From 51f2a7d905b45b8b4b38ee7540d7ec5c935f7145 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sat, 3 Nov 2012 11:23:33 +0100 Subject: [PATCH] Move error messages out of a directive --- src/app/app.js | 4 +++- src/app/login/login.js | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/app.js b/src/app/app.js index 19add5e6..8c5abd03 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -19,7 +19,9 @@ angular.module('app').constant('MONGOLAB_CONFIG', { angular.module('app').constant('I18N.MESSAGES', { 'errors.route.changeError':'Route change error', 'crud.user.save.success':"A user with id '{{id}}' was saved successfully.", - 'crud.user.save.error':"Something went wrong when saving a user..." + 'crud.user.save.error':"Something went wrong when saving a user...", + 'login.error.notAuthorized':"You do not have the necessary access permissions. Do you want to login as someone else?", + 'login.error.notAuthenticated':"You must be logged in to access this part of the application." }); angular.module('app').config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { diff --git a/src/app/login/login.js b/src/app/login/login.js index 698b1bba..e797e4f7 100644 --- a/src/app/login/login.js +++ b/src/app/login/login.js @@ -1,4 +1,4 @@ -angular.module('login', ['services.authentication', 'directives.modal']).directive('loginForm', ['AuthenticationService', 'currentUser', function(AuthenticationService, currentUser) { +angular.module('login', ['services.authentication', 'services.localizedMessages', 'directives.modal']).directive('loginForm', ['AuthenticationService', 'localizedMessages', 'currentUser', function(AuthenticationService, localizedMessages, currentUser) { var directive = { templateUrl: 'login/form.tpl.html', restrict: 'E', @@ -39,9 +39,9 @@ angular.module('login', ['services.authentication', 'directives.modal']).directi case 'unauthorized-client': case 'unauthorized-server': if ( isAuthenticated ) { - message = "You do not have the necessary access permissions. Do you want to login as someone else?"; + message = localizedMessages.get('login.error.notAuthorized'); } else { - message = "You must be logged in to access this part of the application."; + message = localizedMessages.get('login.error.notAuthenticated'); } break; default: