ember-simple-auth: Error: Assertion Failed: The route index was not found - ember-cli

I am building an app with the use of ember-simple-auth.
So it looks very much like the library its doing is thing.
Here is what happens:
user tries to access /dashboard but is redirected to /
the route / contains the login form
the user logs in with valid credentials
Server responds: /token 200 0.252 ms - 52
But an error message is shown: Error: Assertion Failed: The route index was not found
user navigates to /dashboard and can now see the content, navigate around protected areas, and successfully log out.
My question is, how do I define /dashboard as the route instead of index? So that after successful login you are redirected to /dashboard

You can configure Ember Simple Auth's routeAfterAuthentication in the config, e.g.
ENV['ember-simple-auth'] = {
routeAfterAuthentication: 'dashboard'
}

4 years later...
On Ember Simple Auth Part, you can add routeAfterAuthentication and call it a day, because of ESA default to index.
If we dig deeper, as far as why ESA was and still defaults to the Index route, is that Ember always generates 2 routes for you:
one "" for ApplicationRoute
and "/" for IndexRoute,
You get these 2 routes for free.
I found 3.20 version doc's wording is verbose, so I'm pasting from 1.10 doc, but the idea remains the same
On that perspective, ESA uses IndexRoute as default is a safe bet.

Related

TYPO3 Core exception: "Id was out of domain" instead of Error 404

because of some alterings in the page structure many of our pages changed the pid. It does not matter in SEO terms because of speaking urls but there are a bunch of third party links with wrong pids, e. g.:
https://www.myDomain.de/index.php?id=46&no_cache=1&sword_list[0]=someWord
The page with uid 46 exists but is not the meant one, and it now resides under a different domain. So the result is the following exception:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1518472189:
ID was outside the domain | TYPO3\CMS\Core\Error\Http\PageNotFoundException
thrown in file typo3/sysext/frontend/Classes/Controller/ErrorController.php
in line 80. Requested URL:
https://www.myDomain.de/index.php?id=46&no_cache=1&sword_list[0]=someWord
My question:
Can i tell TYPO3 not to throw an exception but to treat all Outside Domain Events simply as 404 with a redirect to the error page?
thanks!
Should be possible by ading an 404 error handling in Site Management module:
Site Management -> Sites -> Yoursite -> Tab "Error hanling" -> Create new
Showing your 404-page with the correct status code in that case is in my experience unfortunately not too obvious.
The simplest for ?id=... with deleted/moved pages (which because of that do not map to the correct site) is to do redirects to useful pages with EXT:redirect or on the webserver level.
That's an example with EXT:redirect:
If there's nothing comparable in the new content that you could redirect to, you can show your 404-page, e.g. by a passthrough ([PT] with Apache mod_rewrite https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html). You should make sure to send a 404 status in that case. (E.g. through .htaccess, a userFunc on the 404-page, ...).
I hope somebody else has a simpler idea.

Outlook Addin Error Code 13005 for auth.getAccessTokenAsync

So I am trying to use single sign on in an outlook addin. I have registered my app at https://apps.dev.microsoft.com/.
In my Manifest I have
<WebApplicationInfo>
<Id>{myId}</Id>
<Resource>api://mydomain.com:3000/{myId}</Resource>
<Scopes>
<Scope>Mail.Read</Scope>
<Scope>profile</Scope>
</Scopes>
</WebApplicationInfo>
mydomain.com is actually a domain i map to my local IP.
Outlook accepts my manifest just fine. How ever when i call Office.context.auth.getAccessTokenAsync, I get the following response
{name: "Invalid application resource Url provided.", message: "Invalid resource Url specified in the manifest.", code: 13004}
How else should i write the resource url. Am i supposed to add this url somewhere else?
I followed https://learn.microsoft.com/en-us/office/dev/add-ins/develop/register-sso-add-in-aad-v2 and was able to get further. But now i Get {name: "Preauthorization missing.", message: "Missing grant for this add-in.", code: 13005}
I was able to solve Error 13005 by adding /taskpane.html to the end of my redirect URI in the authentication tab of my App Registration [Figure 1]. Originally I just had https://loacalhost:3000 as my redirect URI. Just make sure that whatever endpoint the user is being redirected to is the redirect URI. Seems simple but I spent a lot of time on this.
If you can't figure out what your redirect endpoint is, inspect the taskpane element and then look at the top of the tab. It should be something like DevTools - {localhost:3000/taskpane.html}?_... The text inside of the curly braces is the endpoint, make sure that the whole string is added to the Authentication tab in App registrations.
App Registration Page Example Picture
I hope this helps,
Lucius

How to redirect an unauthorized user to the 403 page

I am using ZendFramework2 with zfc-user and ZfcRbac for authorization and access control. I have setup everything to work with database managed role. Now when a user navigate to an un-authorized page, I am getting the error page You are not authorized to access this resource which is thrown by ZfcRbac
Actually I have configured in my zfc-rbac.global.php to redirect to the 403 page. my settings are below.
ZfcRbac\Exception\UnauthorizedException
--
'unauthorized_strategy' => [
'template' => 'error/403'
],
How do I send the user to 403 page?
EDIT
The right answer is to attach the UnauthorizedStrategy in the onBootstrap
$t = $e->getTarget();
$t->getEventManager()->attach(
$t->getServiceManager()->get('\ZfcRbac\View\Strategy\UnauthorizedStrategy')
);
ZfcRbac per default doesn't do anything but throw the exception. The power of ZfcRbac then lies within it's many, many customizable features. The one you should be looking at is found under the Documentation-Section "Strategies".
In short
register the redirection strategy on your Modules onBootstrap
if required, change the redirection strategies configuration

EmberAuth actionRedirectable Module prevents use from accessing a resource by URL

I have the following Auth object in my app:
App.Auth = Ember.Auth.create
signInEndPoint: '/users/sign_in'
signOutEndPoint: '/users/sign_out'
tokenKey: 'auth_token'
tokenIdKey: 'user_id'
userModel: 'App.User'
modules: ['emberModel', 'rememberable', 'actionRedirectable']
actionRedirectable:
signInRoute: 'home'
signOutRoute: 'login'
rememberable:
tokenKey: 'remember_token'
period: 7
autoRecall: true
Everything with authentication is working great. The problem I'm seeing now, though, is that when a user attempts to access, say, 'mydomain.com/#/articles/12' and has a valid remember token, accessing the application is tantamoun to starting a new boot of the application. The user is signed in via remember token, and actionRedirectable takes over and takes the user to HomeRoute instead of going to the requested resource.
I feel like I could get around this by manually transitioning the routes in the relvant login/logout controllers, but I wonder if there's a baked in way of solving this in EmberAuth?
ember-auth dev here.
This looks like a known issue. Try the fix in this comment from github issue #69.
In short, module order does matter. actionRedirectable needs to register the route (probably the article route in your case), before rememberable signs in the user and requests a redirect. Otherwise it would have nowhere to redirect to, and falls back to your home route as specified.
There have already been requests of fixing this unexpected behavior, but I haven't been able to find a fix yet - sorry.

zend_auth causing application to error

i have been following some online screencasts and tutorials about zend_auth.
i have a basic zend application created by the zf tool.
within the index controller index action i place a little code to test if a user is authenticated.
if(!Zend_Auth::getInstance()->hasIdentity())
{
$this->_redirect('login');
}
now as far as i'm aware this should check to see if the current session has been authorised with an identity if it hasnt (ie returns false)
it will redirect the screen to the login controller index action.
all i get is the default error action page stating
An error occurred
Application error
does anyone have an idea wtf is going on.
i have a suspicion it has something to do with needing to set up an autoloader but i have already set an include path to the library folder . (plus i have no issues with accessing controller actions and the likes.
i had another issue with a form stopping my application from rendering anything but i will create another question about that.
thanks keyne setting the error reporting on was a good idea
for some reason i thought i had my app sent to development but it was production.
after looking at the error report i found i had forgotten to create a data folder on my test server to hold the session information.
so zend_auth creating a session failed to location the directory.