fix: Remove invalid session tokens + Login using the Return key
This commit is contained in:
parent
ff26a39db8
commit
6de51609c0
@ -44,6 +44,8 @@ export default class Application extends React.Component<IProps> {
|
|||||||
this.props.setUser(user);
|
this.props.setUser(user);
|
||||||
this.props.setAuthenticated(true);
|
this.props.setAuthenticated(true);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
// The token is invalid, so we should remove it
|
||||||
|
removeSessionToken(window);
|
||||||
this.props.setAuthenticated(false);
|
this.props.setAuthenticated(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -137,6 +139,7 @@ export default class Application extends React.Component<IProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTopTenLearners = (): Promise<TopTen[]> => {
|
getTopTenLearners = (): Promise<TopTen[]> => {
|
||||||
|
// TODO: Deprecate?
|
||||||
const id = this.props.user.classId;
|
const id = this.props.user.classId;
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
fetch(`${BACKEND_URL}/api/class/${id}/topTen`, {
|
fetch(`${BACKEND_URL}/api/class/${id}/topTen`, {
|
||||||
|
@ -65,6 +65,13 @@ const LoginPageWithRouter = withRouter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
// Trigger a login when return is pressed
|
||||||
|
const onEnter = (event: any) => {
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
this.performLogin();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
@ -80,12 +87,14 @@ const LoginPageWithRouter = withRouter(
|
|||||||
<Grid item>
|
<Grid item>
|
||||||
<TextField
|
<TextField
|
||||||
label="Username"
|
label="Username"
|
||||||
|
onKeyPress={onEnter}
|
||||||
inputRef={node => this.usernameRef = node} />
|
inputRef={node => this.usernameRef = node} />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<TextField
|
<TextField
|
||||||
label="Passwort"
|
label="Passwort"
|
||||||
type="password"
|
type="password"
|
||||||
|
onKeyPress={onEnter}
|
||||||
inputRef={node => this.passwordRef = node} />
|
inputRef={node => this.passwordRef = node} />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
|
Reference in New Issue
Block a user