From fbfe1ddeed86e974884faf2e7bd0428ab0af846b Mon Sep 17 00:00:00 2001 From: arnaucode Date: Fri, 1 Sep 2017 11:37:32 +0200 Subject: [PATCH] added accounts verification system --- app.js | 4 ++-- views/main/main.html | 5 ++++- views/navbar.html | 1 + views/navbar.js | 9 +++++++-- views/user/user.html | 7 ++++++- views/user/user.js | 28 ++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 446dd16..011cc4a 100644 --- a/app.js +++ b/app.js @@ -1,8 +1,8 @@ 'use strict'; -var urlapi = "http://localhost:3000/api/"; +//var urlapi = "http://localhost:3000/api/"; //var urlapi = "http://192.168.1.36:3000/api/"; -//var urlapi = "http://37.59.123.45:3000/api/"; +var urlapi = "http://37.59.123.45:3000/api/"; // Declare app level module which depends on views, and components angular.module('adminApp', [ diff --git a/views/main/main.html b/views/main/main.html index 8ff289a..4e3557a 100644 --- a/views/main/main.html +++ b/views/main/main.html @@ -12,7 +12,10 @@ icon
-

{{user.username}}

+

+ {{user.username}} + Validated +

{{user.description}}

{{user.travels.length}} published travels

diff --git a/views/navbar.html b/views/navbar.html index 25d0928..1d5dced 100644 --- a/views/navbar.html +++ b/views/navbar.html @@ -34,6 +34,7 @@
  • Separated link
  • +
  • Logout
  • diff --git a/views/navbar.js b/views/navbar.js index 67435ea..b85a339 100644 --- a/views/navbar.js +++ b/views/navbar.js @@ -10,7 +10,7 @@ angular.module('app.navbar', ['ngRoute']) }]) .controller('NavbarCtrl', function($scope, $http, $routeParams, $location) { - $scope.searchString=""; + $scope.searchString = ""; $scope.locationHash = $location.path(); console.log($scope.locationHash); $scope.goBack = function() { @@ -20,6 +20,11 @@ angular.module('app.navbar', ['ngRoute']) $scope.search = function() { console.log($scope.searchString); - window.location.href="#!/search/" + $scope.searchString; + window.location.href = "#!/search/" + $scope.searchString; + }; + $scope.logout = function() { + localStorage.removeItem("cic_admin_token"); + localStorage.removeItem("cic_admin_userdata"); + window.location.reload(); }; }); diff --git a/views/user/user.html b/views/user/user.html index 49e44ed..e77fc52 100644 --- a/views/user/user.html +++ b/views/user/user.html @@ -12,7 +12,10 @@ icon
    -

    {{user.username}}

    +

    + {{user.username}} + Validated +

    {{user.description}}

    @@ -98,6 +101,8 @@
    +
    Validate User
    +
    Unvalidate User
    Delete user
    diff --git a/views/user/user.js b/views/user/user.js index 3ab6f45..ee6ef19 100644 --- a/views/user/user.js +++ b/views/user/user.js @@ -46,4 +46,32 @@ angular.module('app.user', ['ngRoute']) // failed }); }; + $scope.validateUser = function() { + $http({ + url: urlapi + 'admin/users/validate/id/' + $routeParams.userid, + method: "POST", + data: {} + }) + .then(function(data) { + /*window.location = "#!/main/";*/ + $scope.user = data.data; + }, + function(data) { // optional + // failed + }); + }; + $scope.unvalidateUser = function() { + $http({ + url: urlapi + 'admin/users/unvalidate/id/' + $routeParams.userid, + method: "POST", + data: {} + }) + .then(function(data) { + /*window.location = "#!/main/";*/ + $scope.user = data.data; + }, + function(data) { // optional + // failed + }); + }; });