logo
down
shadow

Login member programmatically on Umbraco 7


Login member programmatically on Umbraco 7

By : user2952656
Date : November 19 2020, 01:01 AM
hope this fix your issue In Umbraco 7 you can use Umbraco.Web.Security.MembershipHelper class.
An instance of it is accessible via Members property in views inheriting from:
code :
  /// <summary> A helper class for handling Members </summary>
  public class MembershipHelper
  {
    public MembershipHelper(ApplicationContext applicationContext, HttpContextBase httpContext);
    public MembershipHelper(UmbracoContext umbracoContext);

    /// <summary> Returns true if the current membership provider is the Umbraco built-in one. </summary>
    public bool IsUmbracoMembershipProviderActive();

    /// <summary> Updates the currently logged in members profile </summary>
    /// <returns> The updated MembershipUser object </returns>
    public Attempt<MembershipUser> UpdateMemberProfile(ProfileModel model);

    /// <summary> Registers a new member </summary>
    /// <param name="model"/><param name="status"/>
    /// <param name="logMemberIn">true to log the member in upon successful registration </param>
    public MembershipUser RegisterMember(RegisterModel model, out MembershipCreateStatus status, bool logMemberIn = true);

    /// A helper method to perform the validation and logging in of a member - this is simply wrapping standard membership provider and asp.net forms auth logic.
    public bool Login(string username, string password);

    /// <summary> Logs out the current member </summary>
    public void Logout();

    public IPublishedContent GetByProviderKey(object key);
    public IPublishedContent GetById(int memberId);
    public IPublishedContent GetByUsername(string username);
    public IPublishedContent GetByEmail(string email);

    /// <summary> Returns the currently logged in member as IPublishedContent </summary>
    public IPublishedContent GetCurrentMember();

    /// <summary> Returns the currently logged in member id, -1 if they are not logged in </summary>
    public int GetCurrentMemberId();

    /// Creates a new profile model filled in with the current members details if they are logged in which allows for editing
    ///             profile properties
    public ProfileModel GetCurrentMemberProfileModel();

    /// Creates a model to use for registering new members with custom member properties
    public RegisterModel CreateRegistrationModel(string memberTypeAlias = null);

    /// Returns the login status model of the currently logged in member, if no member is logged in it returns null;
    public LoginStatusModel GetCurrentLoginStatus();

    /// <summary> Check if a member is logged in </summary>
    public bool IsLoggedIn();

    /// Returns true or false if the currently logged in member is authorized based on the parameters provided
    public bool IsMemberAuthorized(bool allowAll = false, IEnumerable<string> allowTypes = null, IEnumerable<string> allowGroups = null, IEnumerable<int> allowMembers = null);

    /// Changes password for a member/user given the membership provider and the password change model
    public Attempt<PasswordChangedModel> ChangePassword(string username, ChangingPasswordModel passwordModel, string membershipProviderName);
    public Attempt<PasswordChangedModel> ChangePassword(string username, ChangingPasswordModel passwordModel, MembershipProvider membershipProvider);
  }


Share : facebook icon twitter icon
Get Properties from Member in Umbraco programmatically

Get Properties from Member in Umbraco programmatically


By : Muhammad Babar Latif
Date : March 29 2020, 07:55 AM
will be helpful for those in need I thought this would be really simple but .. , Try
code :
Property s = m.getProperty("PreferdUserName").value;
EntityFramework and Umbraco - Use Umbraco Member NodeID as Foreign Key

EntityFramework and Umbraco - Use Umbraco Member NodeID as Foreign Key


By : Skitsanos
Date : March 29 2020, 07:55 AM
hope this fix your issue Because you’re talking about using EF on a database that’s external to the Umbraco database, you won’t be able to take advantage of the ForeignKey attribute. What you can do instead is create a computed (NotMapped) property on your model and linking that to the Umbraco Member object, via the MemberId property that’s stored in your external database... something like this perhaps:
code :
public class Example {

    public int Key { get; set; }

    public int MemberId { get; set; }

    [NotMapped]
    public Member Entity {
        get 
        {
            return Umbraco.Core.ApplicationContext.Current.Services.Members.GetById(MemberId);
        }
        set
        {
            MemberId = value.Id;
        }
    }

}
After migrating Umbraco web from IIS 7.5 to 8.5 member login not working on Firefox (only) - Forms auth cookie not set

After migrating Umbraco web from IIS 7.5 to 8.5 member login not working on Firefox (only) - Forms auth cookie not set


By : Hitchhiker
Date : March 29 2020, 07:55 AM
Umbraco: How to check if a member is allowed to access a page programmatically

Umbraco: How to check if a member is allowed to access a page programmatically


By : user3022986
Date : March 29 2020, 07:55 AM
will be helpful for those in need I'm setting up a Umbraco 8 site for creating a prototype. , I got it working this way:
code :
IContent content = base.Services.ContentService.GetById(item.Id);
PublicAccessEntry entry = base.Services.PublicAccessService.GetEntryForContent(content);
if (entry != null)
{
    foreach (var r in entry.Rules)
    {
        if (Roles.IsUserInRole(r.RuleValue))
        {
            <a class="nav-link @(item.IsAncestorOrSelf(Model) ? "nav-link--active" : null)" href="@item.Url">@item.Name</a>
        }
    }
}
else
{
    <a class="nav-link @(item.IsAncestorOrSelf(Model) ? "nav-link--active" : null)" href="@item.Url">@item.Name</a>
}
Creating a new member programmatically in Umbraco

Creating a new member programmatically in Umbraco


By : Jan Aertgeerts
Date : March 29 2020, 07:55 AM
it helps some times If you are using umbraco 7 it is best to user the member service. Below is a simple approach you could employ to achieve this.
Related Posts Related Posts :
  • What could be causing my WhatsApp Stickers Pack not to work?
  • How Can I Reorder/Sort The Collections List in Directus?
  • Is this language generic/mighty enough to be used for a generic game AI?
  • graphite, use regular expressions to select the target, or an alternative
  • subtract functions with type real in ml
  • how to filter '(' in navision 2013
  • sending sms from a mobile browser
  • NuGet behind firewall
  • Gstreamer hangs while generating timelapse from JPEGs on Raspberry pi
  • How to retrieve total view count of large number of pages combined from the GA API
  • Websites rich with exercices or explanation for SML?
  • Is there a TempData equivalent in ServiceStack?
  • scipy-0.12.0 failing to install on mountain lion using python setup.py install
  • Looking for simplest option to render Razor cshtml pages in a console application without any web server
  • Evaluating variables at a specific time in Modelica
  • When I run the Application, only "web" engine is running in GlassFish. "webservices" is not started
  • How To Set MIME Type Of Google Drive File
  • Remove Missing Values in Weka
  • Reloading a UICollectionView using reloadData method returns immediately before reloading data
  • carrot2 - can I cluster documents from a folder?
  • StreamSocket has no Close Implementation in C#
  • Rails, Foundation 4, Respond.js not working properly in IE8
  • How can i create imagesurface from cairo xlib's Graphics Context using cairo and x11 Api's?
  • CKEditor "overflow: scroll" on parent causes toolbar to freeze at initial position
  • Differences between components and controls in ENYO
  • Photoshop making isometric?
  • Does Intel IPP 8.0 support in-place operations?
  • What is Object dictionary in CANOpen?
  • Example of orbBasic Indexed User Variables
  • convert to ABSOLUTE in logback
  • How to conditionally download file using p:fileDownload
  • Error on pod install
  • Set HTTP GET Parameters in Finagle
  • different attack that uses sql injection
  • How can I change my xampp username not as 'root'
  • AMQP Content header payload structure
  • Apache POI formula evaluation not working for Excel IF
  • How can I trace RESTEasy's dispatch?
  • Map Freezes on iOS 7 with Google Maps SDK 1.4
  • Comparing lists, is the subset list within the first list
  • Non-ascii character highlight in Sublime Text 2
  • Installing Magit in Aquamacs
  • Receiving error - System.Net.Mail.SmtpException: 4.3.2 try again later
  • Coreaudio render callback in monotouch
  • The command 'yarn --v' also initiates 'yarn install' and installs packages automatically. Why is this happening?
  • save multiple matches in a list (grep or awk)
  • Can a number register be used in a groff request?
  • Mapping FAQ with RASA for large dataset (2000+)
  • Fragment not receiving LiveData updates after remove + add
  • FitText.js makes text bigger rather than smaller
  • ARM - Implementing stack with load/store multiple register values
  • How to check if a ChromeCast Session is already in progress
  • ngForm inside a Carousel Slide in UI Bootstrap not working
  • Clearing attributes in Tritium
  • "vagrant up" failing: Vagrant VM failed to remain in the running state
  • ftsearch returning empty docs
  • What are the advantages of setting "hive.exec.parallel" to false in Hive ?
  • Creating a root certificate in FiddlerCore
  • How to access app.config in a blueprint?
  • DB2 RECORDSET table name converted to uppercase
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org