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 2054 posts 7103 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 487 posts 2990 karma points MVP 8x admin c-trib
    Aug 05, 2015 @ 18:38
    Anders Bjerner
    102

    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.

Please Sign in or register to post replies

Write your reply to:

Draft