Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Cimplex 101 posts 553 karma points
    Oct 23, 2019 @ 18:46
    Cimplex
    0

    2FA - Umbraco 8 - Redirect to backoffice after successful code

    Howdy!

    We have two factor authentication enabled for our Umbraco site, in Umbraco 7 we used this code snippet to verify the 2fa code:

    authResource.verify2FACode(provider, code)
                    .then(function (data) {
                        userService.setAuthenticationSuccessful(data);
                        $scope.submit(true);
                    }, function(response) {
                        $scope.error = true;
                    });
    

    Now the $scope.submit(true) throws a error:

    TypeError: $scope.submit is not a function
    

    And the user is not redirected to the backoffice. If the page is reloaded manually (F5) the backoffice appear as expected, means that the cookie is set correctly.

    Any ideas how to solve this?

    / Herman

  • Thomas Maassen 3 posts 73 karma points
    1 week ago
    Thomas Maassen
    0

    I think this means angularJs does not have a built in function for $scope.submit anymore, but not sure.

    I have been working on a 2fa package for Umbraco 8 that will we released later this week or next week and I solved this by using a different function to refresh the page.

    I hardcoded the backoffice URL and allowed that URL to be changed in a constants file. If you swap $scope.submit for this line it should work:

    $window.location.href = '/umbraco';
    

    For this to work you will have to inject $window in your controller like you did with $scope and authResource. If you have a different backoffice URL you should ofcourse put that in the string instead of /umbraco

  • Cimplex 101 posts 553 karma points
    1 week ago
    Cimplex
    0

    Hi Thomas,

    Thanks for the reply, that's how i solved it as well, bad thing about this is if your automatically logged out from Umbraco all your changes will be gone because of the redirect.

    // Herman

  • Thomas Maassen 3 posts 73 karma points
    1 week ago
    Thomas Maassen
    0

    It's not my favorite solution either, but it's the only one I could get to work. Normally i use a different method in the angular controllers to refresh the page:$route.reload(). But when i use that method in the login controler it updates the URL but it doesn't refresh the view so for now this seems to be the only way

Please Sign in or register to post replies

Write your reply to:

Draft