Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#345 | Admin session handling improved #355

Merged
merged 8 commits into from
Mar 26, 2021

Conversation

szymon-owczarzak
Copy link
Contributor

Description

  • Admin Session extended to 5 hours
  • Admin Session will be refreshed on every POST and DELETE request.

Motivation and Context

It was quite easy to lost changes made to boards due to session expiration.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • Automated functional tests have been added or modified to cover my changes (if applicable)
  • I have updated the documentation accordingly.

I hereby agree to the terms of the Cogboard Contributor License Agreement.

}

val SESSION_REFRESHERS = setOf(HttpMethod.POST, HttpMethod.DELETE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All POST and DELETE should now refresh the session

import io.vertx.reactivex.ext.auth.jwt.JWTAuth
import io.vertx.reactivex.ext.web.RoutingContext

open class JwtCommon {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common logic for handling JWT token

.then(response => response.json());
.then(response => {
if (response.headers.get('token')) {
setToken(response.headers.get('token'));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any API response can potentially contain refreshed token

@@ -91,8 +91,7 @@ export const login = (credentials, loginAsGuest) => dispatch => {
dispatch(pushNotification(NOTIFICATIONS.LOGIN(`Guest: ${guestName}`)));
} else {
return fetchData(URL.LOGIN, { method: 'POST', data: credentials }).then(
({ token }) => {
setToken(token);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to fetchData

@@ -66,7 +66,7 @@ Cypress.Commands.add(
username: username,
password: password
}).then(response => {
const loginBody = response.body.token.split(' ');
const loginBody = response.headers['token'].split(' ');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the token is now returned as a header - as it should be from the begining

devzbysiu
devzbysiu previously approved these changes Mar 25, 2021
@szymon-owczarzak szymon-owczarzak added the enhancement New feature or request label Mar 26, 2021
@szymon-owczarzak szymon-owczarzak self-assigned this Mar 26, 2021
@szymon-owczarzak szymon-owczarzak merged commit 78c4df6 into master Mar 26, 2021
@szymon-owczarzak szymon-owczarzak deleted the user-session-refreshed-on-save-and-update branch March 26, 2021 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants