2014-12-30 2 views
3

나는 이것과 함께 싸우고 있습니다. Umbraco 6에서 쉽게 사용하여이 작업을 수행 할 수 있습니다 :로그인 회원이 프로그래밍 방식으로 Umbraco 7

Member.AddMemberToCache(
    Member.GetMemberFromEmail(email), 
    true, 
    new TimeSpan(0, 30, 0) 
); 

나는 umbraco (7) 회원의 서비스에서 같은 일을 찾을 수 없습니다. 어떤 아이디어?

답변

3

Umbraco 7에서는 Umbraco.Web.Security.MembershipHelper 클래스를 사용할 수 있습니다.

    : 상속 컨트롤러로도

    • Umbraco.Web.Mvc.UmbracoTemplatePage
    • Umbraco.Web.Mvc.UmbracoViewPage
    • Umbraco.Web.Mvc.UmbracoViewPage<T>

    :
    그것의 인스턴스는 뷰에서 속성에서 상속 회원을 통해 액세스 프로그래밍

  • Umbraco.Web.WebApi.UmbracoApiController
  • Umbraco.Web.Mvc.SurfaceController

로그인하는 회원 :Members.GetByEmail("email"); // returns IPublishedContent

전체 공용 인터페이스의 Umbraco.Web.Security.MembershipHelper 클래스 :

/// <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); 
    } 
,536
Members.Login("username", "password");
이메일을 통해 회원을 뽑아
+0

감사합니다. 잠시 후에 해결 방법을 찾았지만 매우 유용했기 때문에 몇 사람이 유용하다고 생각합니다. –

관련 문제