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

add routeAfterAuthentication to the README #2285

Closed
wants to merge 1 commit into from

Conversation

mcfiredrill
Copy link
Contributor

Also I linked to the API docs on the "configurable route" text.

@mcfiredrill
Copy link
Contributor Author

mcfiredrill commented Mar 26, 2021

My bad, I realized this method of configuring routeAfterAuthentication was dropped in favor of the mixin.
However the mixin is now deprecated.
So how exactly does one set routeAfterAuthentication ???

I searched the discord a bit and found someone who got it working by extending ember-simple-auth session service and overwriting the handleAuthentication() method. Is this the recommended solution?
https://discord.com/channels/480462759797063690/496695347582861334/738599436917407934

import SimpleAuthSessionService from 'ember-simple-auth/services/session';
import { inject as service } from '@ember/service';

export default class SessionService extends SimpleAuthSessionService {
    /**
     * Inject the router service
     *
     * @var {Service}
     */
    @service router;

    /**
     * Inject the current user service
     *
     * @var {Service}
     */
    @service currentUser;

    /**
     * Overwrite the handle authentication method
     *
     * @var {Service}
     */
    handleAuthentication() {
        this.router.transitionTo('dashboard.boards');
        this.loadCurrentUser();
    }

    /**
     * Loads the current authenticated user
     *
     * @void
     */
    async loadCurrentUser() {
        try {
            const user = await this.currentUser.load();
            return user;
        } catch (err) {
            await this.session.invalidate();
        }
    }
}

Also I linked to the API docs on the "configurable route" text.
@marcoow
Copy link
Member

marcoow commented May 7, 2021

Yes, what you found is the recommended solution 👍

@marcoow marcoow closed this May 7, 2021
@mcfiredrill
Copy link
Contributor Author

Yes, what you found is the recommended solution +1

All right thanks in that case I will add some docs for that in another PR. 🙆

@mcfiredrill mcfiredrill deleted the patch-3 branch May 16, 2021 04:49
mcfiredrill added a commit to mcfiredrill/ember-simple-auth that referenced this pull request Jun 18, 2021
Continuing from my comment here, there isn't any info about this in the docs so yet.
mainmatter#2285 (comment)
mcfiredrill added a commit to mcfiredrill/ember-simple-auth that referenced this pull request Jun 18, 2021
Continuing from my comment here, there isn't any info about this in the docs so yet.
mainmatter#2285 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants