Copied to clipboard

Flag this post as spam?

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


  • Nicholas Westby 2005 posts 6843 karma points c-trib
    Aug 05, 2015 @ 18:22
    Nicholas Westby
    0

    How to Impersonate Umbraco Member?

    Suppose I want members to be able to login with either of two techniques:

    • With their username/password.
    • With an auto-generated secret key (e.g., sent in an email as a query string parameter on a link to the site).

    Is there some way of logging that member in with that secret key so that all the authorization stuff still functions?

  • Anders Bjerner 448 posts 2601 karma points MVP 4x admin c-trib
    Aug 05, 2015 @ 18:38
    Anders Bjerner
    101

    You can use the FormAuthentication class to set an auth cookie like:

    FormsAuthentication.SetAuthCookie(username);
    

    Or with a persistent cookie:

    FormsAuthentication.SetAuthCookie(username, true);
    

    Since this only sets a cookie, you must redirect the user (or simply refresh the page) before the user is actually logged in.

    You can then make relevant checks before setting the auth cookie.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies