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