mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-28 11:16:52 +01:00
improve (login): redirect the user to the login screen once the session expire
This commit is contained in:
parent
7f8c47c186
commit
a02510418d
4 changed files with 15 additions and 1 deletions
|
|
@ -98,6 +98,9 @@ class FileSystem{
|
|||
return store;
|
||||
});
|
||||
}).catch((_err) => {
|
||||
if(_err.code === "Unauthorized"){
|
||||
location = "/login?next="+location.pathname;
|
||||
}
|
||||
this.obs.next(_err);
|
||||
return Promise.reject(null);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ export class ConnectPage extends React.Component {
|
|||
|
||||
componentWillMount(){
|
||||
const urlData = urlParams();
|
||||
if(Object.keys(urlData).length === 0){
|
||||
const get_params = Object.keys(urlData);
|
||||
if(get_params.length === 0){
|
||||
return;
|
||||
}else if(get_params.length === 1 && !!urlData["next"]){
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -40,6 +43,9 @@ export class ConnectPage extends React.Component {
|
|||
Session.authenticate(params)
|
||||
.then(Session.currentUser)
|
||||
.then((user) => {
|
||||
if(location.search.indexOf("?next=") === 0){
|
||||
location = urlParams()["next"];
|
||||
}
|
||||
let url = '/files/';
|
||||
let path = user.home;
|
||||
if(path){
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ var (
|
|||
ErrNotImplemented = NewError("Not Implemented", 501)
|
||||
ErrFilesystemError = NewError("Can't use filesystem", 503)
|
||||
ErrMissingDependency = NewError("Missing dependency", 424)
|
||||
ErrNotAuthorized = NewError("Not authorized", 401)
|
||||
)
|
||||
|
||||
type AppError struct {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,10 @@ func SessionStart (fn func(App, http.ResponseWriter, *http.Request)) func(ctx Ap
|
|||
return
|
||||
}
|
||||
if ctx.Backend, err = _extractBackend(req, &ctx); err != nil {
|
||||
if len(ctx.Session) == 0 {
|
||||
SendErrorResult(res, ErrNotAuthorized)
|
||||
return
|
||||
}
|
||||
SendErrorResult(res, err)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue