Specific use cases:
- “forgot my password” account restore token
- “verify it’s my e-mail address” token
User gets an email with a request like abc.com/?token=abcdef
User clicks the link and the system processes the token.
What I have so far: (this code is in the LoginScreen class)
@Subscribe
private fun onInit(event: InitEvent) {
val handleVaadinRequestFunction: (session: VaadinSession, request: VaadinRequest, response: VaadinResponse) -> Boolean =
{ session, request, response -> handleVaadinRequest(request) }
AppUI.getCurrent()?.let { ui ->
// Handle current request
VaadinRequest.getCurrent()?.let { currentRequest ->
handleVaadinRequest(currentRequest)
}
// Handle future requests on initialized UI
// https://vaadin.com/docs/v7/framework/advanced/advanced-requesthandler
ui.session.removeRequestHandler(handleVaadinRequestFunction)
ui.session.addRequestHandler(handleVaadinRequestFunction)
}
}
private fun handleVaadinRequest(request: VaadinRequest?): Boolean {
request?.getParameter("resetpasswordtoken")?.let { token ->
log.info("resetpasswordtoken retrieved: $token")
// ... do some stuff with the token
}
}
This works unreliably and I don’t know why. As this is a quite common use case, I wonder if there is a “proper” way of doing it?