Skip to content

Commit

Permalink
cookie now set by beckend
Browse files Browse the repository at this point in the history
  • Loading branch information
salimkanoun committed Oct 8, 2020
1 parent b0445df commit c0664b3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
3 changes: 2 additions & 1 deletion BackEnd/controllers/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ authentication = async function (req, res) {

var TOKEN = jwt.sign(payload, process.env.TOKEN_SECRET, { expiresIn: '1h' });

res.json(TOKEN);
res.cookie("tokenOrthancJs", TOKEN, {secure: true, httpOnly: true})
res.json(true)
})
} else {
res.status(401).send('Wrong Credential')
Expand Down
12 changes: 2 additions & 10 deletions FrontEnd/src/components/Authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,12 @@ export default class Authentication extends Component {

await apis.authentication.logIn(postData).then((answer)=>{

console.log(answer)
// get token from fetch request
const token = answer;

//cookie's options
var d = new Date();
d.setTime(d.getTime() + (7*24*60*60*1000)); // cookie expire in 7 days
var expires = d.toUTCString();

// set token in cookie
document.cookie = `tokenOrthancJs=${token}; expires=${expires}`
document.cookie = `tokenOrthancJs=${token}; expires=${expires};HttpOnly`

newState = {
accessCheck : answer
accessCheck : true
}

}).catch( async (error) => {
Expand Down
1 change: 0 additions & 1 deletion FrontEnd/src/components/CDBurner/CDBurner.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export default class CDBurner extends Component {
};

render(){
console.log(this.state.burnerJobs)
return (

<div className='jumbotron'>
Expand Down

0 comments on commit c0664b3

Please sign in to comment.