user_signed_in?in apps, pages and components.
authenticate_user!in a before action.
Profile::App. If we want to take advantage of Matestack's transitions features (not reloading our app layout between page transitions) we can not use devise views, because we would need to redirect to them and therefore need to reload the whole page. Requiring us for example to implement our navigation twice. In our
Profile::Appand also in our devise sign in view.
togglecomponent which gets shown when the event
sign_in_failureis emitted. This event gets emitted in case our form submit was unsuccessful as we specified it in our
form_confighash. If the form is successful our app will make a transition to the page the server would redirect to.
newaction in order to render our sign in page and set the correct Matestack app in the controller. Also remember to include the components registry. This is necessary if you use custom components in your app or page, because without it Matestack can't resolve them.
formcomponent recieves the response of the
newaction, which would have a success status. Therefore it redirects you resulting in a rerendering of the sign in page. So our
formcomponent needs to recieve a error code in order to work as expected. To achieve this we need to provide a custom failure app.
lib/devise/json_failure_app.rbcontaining following code:
application/jsonas content type, setting the status to a 401 unauthorized error and the content_type to json.
matestack_formcomponent triggers the
sign_in_failureevent, which sets off our
togglecomponent resulting in displaying the error message.
method: :getin the configuration hash. We use a http GET request to sign out, because the browser will follow the redirect send from devise session controller and then Matestack tries to load the page where we have been redirected to. When we would use a DELETE request the action we would be redirected to from the browser will be also requested with a http DELETE request, which will result in a rails routing error. Therefore we use GET and need to configure devise accordingly by changing the