I am currently trying to display a error message if a user inputs a wrong username or password. The tricky part is that I am not using EJS or Handlebars, or any kind of template engine but raw HTML with Bootstrap.
I saw one other good question Good Similar Question of how to pass values from Nodejs to Angular. Sadly this didn't seem to help.
Here is my NodeJS + Passport User Authentication function:
function isLoggedIn(req, res, next) {
console.log('here is Authenticated', req.isAuthenticated());
if (req.isAuthenticated()){
return next();
}else{
res.json({"message": "Failed login. Wrong Username or Password"});
res.redirect('/login');
console.log("NO PERMISSION HAS BEEN GIVEN");
}
}
So my Idea was to send the message as an JSON object and get
it with Angular:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("/login").then(function(data){
$scope.message = data;
console.log("message loaded" + data);
});
});
and of course I am trying to display the message with .
Sadly this method is not working, I am trying a second way which involves using ng-show
.
Can I pass a NodeJS function to a ng-show
? Something similar to:
<div class="alert alert-danger" ng-show="isAuthenticated = true">
<p> Failed login message </p>
</div>
If not, how can I display a failed login message to a static html file without using jade, handlebars or any other template engine?
via ZombieChowder
No comments:
Post a Comment