mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 11:22:40 +00:00
Make local login route conditional and rename
This commit is contained in:
@@ -44,7 +44,7 @@ const Account = createClass({
|
|||||||
const expiry = new Date;
|
const expiry = new Date;
|
||||||
expiry.setFullYear(expiry.getFullYear() + 1);
|
expiry.setFullYear(expiry.getFullYear() + 1);
|
||||||
|
|
||||||
const token = await request.post('/login')
|
const token = await request.post('/local/login')
|
||||||
.send({ username })
|
.send({ username })
|
||||||
.then((response)=>{
|
.then((response)=>{
|
||||||
return response.body;
|
return response.body;
|
||||||
|
|||||||
@@ -261,20 +261,17 @@ app.get('/print/:id', asyncHandler(async (req, res, next)=>{
|
|||||||
|
|
||||||
const nodeEnv = config.get('node_env');
|
const nodeEnv = config.get('node_env');
|
||||||
const isLocalEnvironment = config.get('local_environments').includes(nodeEnv);
|
const isLocalEnvironment = config.get('local_environments').includes(nodeEnv);
|
||||||
// Login
|
// Local only
|
||||||
app.post('/login', (req, res)=>{
|
if(isLocalEnvironment){
|
||||||
// Local only
|
// Login
|
||||||
if(!isLocalEnvironment){
|
app.post('/local/login', (req, res)=>{
|
||||||
|
const username = req.body.username;
|
||||||
|
if(!username) return;
|
||||||
|
|
||||||
return;
|
const payload = jwt.encode({ username: username, issued: new Date }, config.get('secret'));
|
||||||
}
|
return res.json(payload);
|
||||||
|
});
|
||||||
const username = req.body.username;
|
}
|
||||||
if(!username) return;
|
|
||||||
|
|
||||||
const payload = jwt.encode({ username: username, issued: new Date }, config.get('secret'));
|
|
||||||
return res.json(payload);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user