sails-adminpanel
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -22,2 +22,4 @@ 'use strict'; | ||
if (sails.config.adminpanel.auth) req.locals.user = req.session.UserAP; | ||
var fields = fieldsHelper.getFields(req, instance, 'add'); | ||
@@ -24,0 +26,0 @@ var data = {}; //list of field values |
@@ -15,7 +15,10 @@ 'use strict'; | ||
if (!req.session.UserAP && sails.config.adminpanel.auth) { | ||
return res.redirect('/admin/userap/login'); | ||
} | ||
if (sails.config.adminpanel.auth) req.locals.user = req.session.UserAP; | ||
return res.viewAdmin('dashboard',{ instance: "instance"}); | ||
}; |
@@ -29,2 +29,4 @@ 'use strict'; | ||
if (sails.config.adminpanel.auth) req.locals.user = req.session.UserAP; | ||
instance.model.findOne(req.param('id')) | ||
@@ -31,0 +33,0 @@ .populateAll() |
@@ -15,2 +15,4 @@ "use strict"; | ||
if (sails.config.adminpanel.auth) req.locals.user = req.session.UserAP; | ||
let records = []; | ||
@@ -17,0 +19,0 @@ var fields = fieldsHelper.getFields(req, instance, 'list'); |
@@ -30,2 +30,4 @@ 'use strict'; | ||
if (sails.config.adminpanel.auth) req.locals.user = req.session.UserAP; | ||
var total = 0; | ||
@@ -32,0 +34,0 @@ var records = []; |
@@ -1,28 +0,34 @@ | ||
'use strict'; | ||
"use strict"; | ||
var passwordHash = require('password-hash'); | ||
var passwordHash = require("password-hash"); | ||
var created = false; | ||
module.exports = function(req, res) { | ||
if (req.url.indexOf('login') >= 0) { | ||
if (req.method.toUpperCase() === 'POST') { | ||
var username = req.param('username'); | ||
var password = req.param('password'); | ||
UserAP.findOne({username: username}).exec((err, user) => { | ||
if (err) return res.serverError(err); | ||
if (!user) return res.notFound(); | ||
if (passwordHash.verify(username + password, user.passwordHashed)) { | ||
req.session.UserAP = user; | ||
res.redirect('/admin/'); | ||
} else { | ||
res.forbidden('Wrong username/password'); | ||
} | ||
}); | ||
} else if (req.method.toUpperCase() === 'GET') { | ||
return res.viewAdmin('login'); | ||
module.exports = function (req, res) { | ||
if (req.url.indexOf("login") >= 0) { | ||
if (req.method.toUpperCase() === "POST") { | ||
var username = req.param("username"); | ||
var password = req.param("password"); | ||
UserAP.findOne({ username: username }).exec((err, user) => { | ||
if (err) return res.serverError(err); | ||
if (!user) { | ||
req.flash("adminError", "Wrong username or password"); | ||
return res.viewAdmin("login"); | ||
} else { | ||
if (passwordHash.verify(username + password, user.passwordHashed)) { | ||
req.session.UserAP = user; | ||
return res.redirect("/admin/"); | ||
} else { | ||
req.flash("adminError", "Wrong username or password"); | ||
return res.viewAdmin("login"); | ||
} | ||
} | ||
} else if (req.url.indexOf('logout') >= 0) { | ||
req.session.UserAP = undefined; | ||
res.redirect('/admin/'); | ||
}); | ||
} | ||
if (req.method.toUpperCase() === "GET") { | ||
return res.viewAdmin("login"); | ||
} | ||
} else if (req.url.indexOf("logout") >= 0) { | ||
req.session.UserAP = undefined; | ||
res.redirect("/admin/userap/login"); | ||
} | ||
}; |
@@ -22,2 +22,5 @@ 'use strict'; | ||
return res.redirect('/admin/userap/login'); | ||
if (sails.config.adminpanel.auth) req.locals.user = req.session.UserAP; | ||
/** | ||
@@ -24,0 +27,0 @@ * Searching for record by model |
@@ -22,2 +22,4 @@ 'use strict'; | ||
if (sails.config.adminpanel.auth) req.locals.user = req.session.UserAP; | ||
if (req.method.toUpperCase() === 'POST') { | ||
@@ -24,0 +26,0 @@ // if this file must not be loaded |
@@ -26,2 +26,4 @@ 'use strict'; | ||
if (sails.config.adminpanel.auth) req.locals.user = req.session.UserAP; | ||
var query = instance.model | ||
@@ -28,0 +30,0 @@ .findOne(req.param('id')) |
@@ -49,3 +49,3 @@ { | ||
}, | ||
"version": "1.2.0" | ||
"version": "1.2.1" | ||
} |
@@ -122,2 +122,5 @@ sails-adminpanel readme for sails v1.x | ||
Clarity docs https://vmware.github.io/clarity/documentation/v0.13/ | ||
## License | ||
@@ -124,0 +127,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9230116
94232
129
0