Ember js with tomcat

Hi, I am new to ember js, have created my front end with ember js and deployed the build in tomcat. I have used form based authentication to authenticate the user. I have some queries like how to disable a button in hbs based on logged in user role( like request.isUserRoleIn in jsp page) I have not used any ember simple-auth since my jaasrealm take care of authentication.

Hi Dinesh.

Since the Ember app runs independently in the browser, if you want it to know about things like the login status you’ll need to expose an API endpoint for it to ask the server about that.

The minimum necessary is usually an endpoint that checks whether the user has a valid login. Accessing this is just like fetching any other kind of data into the ember app. So the ember app could fetch('/is-my-login-valid').

You do get a lot of nice things taken care of automatically if you use ember-simple-auth, so that is a good way to go. For example, it makes it easier to keep the login state synchronized across browser tabs. If you use ember-simple-auth, you’ll still want to have an endpoint for checking the login status, and you would call it from you authenticator’s restore method. You would also need to implement authenticate which establishes new sessions. Typically this would take the actual username & password as input and send them to server, but if you want to keep using a server-rendered login form instead, your authenticate method could just use the user’s existing cookies. In this case, you’re only calling authenticate to make ember-simple-auth aware of the cookie-based session that was already established separately, before the ember app even booted.

1 Like