Skip to content

Commit

Permalink
D1.2: Criar uma tela que apenas logados podem entrar (com logout)
Browse files Browse the repository at this point in the history
  • Loading branch information
makah committed Mar 28, 2016
1 parent b385902 commit 9b9776f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 8 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Exemplo de uso: Chaveiro/Cliente; Médico/Paciente; Possuidor de Carro/Cliente;
3. Primeiro Commit

#### D1 ####
1. Implementar o Passport básico criado por [Giancarlo Soverini](http://iliketomatoes.com/implement-passport-js-authentication-with-sails-js-0-10-2/)
1. Implementar o Passport básico criado por [Giancarlo Soverini](http://iliketomatoes.com/implement-passport-js-authentication-with-sails-js-0-10-2/) [commit](https://github.com/makah/FirstSailsProject/commit/811912dec01ab3d58142e4dceea6f2601c7e91d1)
2. Criar uma tela que apenas logados podem entrar (com logout)
3. Enviar o password encriptado para o servidor
4. Criar esqueci minha senha
5. Criar login pelo Google/Facebook

fdsa
5 changes: 1 addition & 4 deletions api/controllers/AuthController.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ module.exports = {
if (err)
return res.send(err);

return res.send({
message: info.message,
user: user
});
return res.redirect('/private');
});

})(req, res);
Expand Down
15 changes: 15 additions & 0 deletions api/controllers/DashboardController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* DashboardController
*
* @description :: Server-side logic for managing Dashboards
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/

module.exports = {


index: function(req, res){
res.view();
}
};

14 changes: 14 additions & 0 deletions api/models/Dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Dashboard.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/documentation/concepts/models-and-orm/models
*/

module.exports = {

attributes: {

}
};

2 changes: 1 addition & 1 deletion api/policies/isAuthenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = function(req, res, next) {
return next();
}
else{
return res.redirect('/login');
return res.redirect('/');
}
};
2 changes: 1 addition & 1 deletion config/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports.policies = {

'*': true,

'PostController': {
'DashboardController': {
'*': 'isAuthenticated'
},

Expand Down
2 changes: 2 additions & 0 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module.exports.routes = {
'get /login': {
view: 'static/login'
},

'/private': 'DashboardController.index',

'post /login': 'AuthController.login',

Expand Down
4 changes: 4 additions & 0 deletions views/dashboard/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<h1> You are in a Private Area</h1>

<a href="/logout">Logout</a>

0 comments on commit 9b9776f

Please sign in to comment.