Base solution for your next web application
From Nov 21
To Dec 1
Also valid for the
existing customers!
Open Closed

Sample app: unify Auth & Unauth angular JS apps #6

nicnewdigate created

For the sample application, do you have any suggestions how I can use the same Angular SPA for authenticated users and non-authenticated users? Currently, the user is redirected to the login page if they are not logged in. I could have a separate angular app for unauthenticated users, but this will introduce redundancy because unauthenticated users share certain features - say for instance - the public/unauthenticated users should be able to see a list of questions and answers, but only authenticated users will be able to post questions and answers.

Any insight would be appreciated.


2 Answer(s)
  • 0
    hikalkan created
    Support Team

    First of all, if your application will be public, you should also think about SEO if you're using Angular (Fortunately there are some solutions but you should take care of it).

    Actually, it's simple. In the sample app (<a class="postlink" href=""> ... ter/sample</a>), you should remove [AbpAuthorize] of the HomeController. Then MVC will not redirect to login.

    In your angular application, you should check if user logged in and show some menus/links. You should only authorize needed app service methods, not all.

  • 0
    nicnewdigate created

    Thanks @hikalkan! Wow - I wasn't expecting it to be that easy! I'll give it a go.

    Yes I heard that SPAs are notoriously bad with SEO! My buddy says something about a hashbang! I'll have to go investigate it!

    Thanks again :)