<commit_before>﻿using System;
using System.Web.Security;
using Orchard.Environment;

namespace Orchard.Security.Providers {
    public class OrchardMembershipProvider : MembershipProvider {

        static IMembershipService GetService() {
            return ServiceLocator.Resolve<IMembershipService>();
        }

        static MembershipSettings GetSettings() {
            return GetService().GetSettings();
        }

        private MembershipUser BuildMembershipUser(IUser user) {
            return new MembershipUser(Name,
                user.UserName,
                user.Id,
                user.Email,
                null,
                null,
                true,
                false,
                DateTime.UtcNow,
                DateTime.UtcNow,
                DateTime.UtcNow,
                DateTime.UtcNow,
                DateTime.UtcNow);
        }

        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) {
            var user = GetService().CreateUser(new CreateUserParams(username, password, email, passwordQuestion, passwordAnswer, isApproved));

            if (user == null) {
                status = MembershipCreateStatus.ProviderError;
                return null;
            }

            status = MembershipCreateStatus.Success;
            return BuildMembershipUser(user);
        }


        public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) {
            throw new NotImplementedException();
        }

        public override string GetPassword(string username, string answer) {
            throw new NotImplementedException();
        }

        public override bool ChangePassword(string username, string oldPassword, string newPassword) {
            var service = GetService();
            var user = service.ValidateUser(username, oldPassword);
            if (user == null)
                return false;
            service.SetPassword(user, newPassword);<commit_msg>Fixing remarkably basic mistake from the last commit.<commit_after>﻿using System;
using System.Web.Security;
using Orchard.Environment;

namespace Orchard.Security.Providers {
    public class OrchardMembershipProvider : MembershipProvider {

        static IMembershipService GetService() {
            return ServiceLocator.Resolve<IMembershipService>();
        }

        static MembershipSettings GetSettings() {
            return GetService().GetSettings();
        }

        private MembershipUser BuildMembershipUser(IUser user) {
            return new MembershipUser(Name,
                user.UserName,
                user.Id,
                user.Email,
                null,
                null,
                true,
                false,
                DateTime.UtcNow,
                DateTime.UtcNow,
                DateTime.UtcNow,
                DateTime.UtcNow,
                DateTime.UtcNow);
        }

        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) {
            var user = GetService().CreateUser(new CreateUserParams(username, password, email, passwordQuestion, passwordAnswer, isApproved));

            if (user == null) {
                status = MembershipCreateStatus.ProviderError;
                return null;
            }

            status = MembershipCreateStatus.Success;
            return BuildMembershipUser(user);
        }


        public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) {
            throw new NotImplementedException();
        }

        public override string GetPassword(string username, string answer) {
            throw new NotImplementedException();
        }

        public override bool ChangePassword(string username, string oldPassword, string newPassword) {
            var service = GetService();
            var user = service.ValidateUser(username, oldPassword);
            if (user == null)
                return false;

            service.SetPassword(user, newPassword);
            return true;
{'fraction_non_alphanumeric': 0.06633574007220217, 'fraction_numerical': 0.0, 'mean_word_length': 2.117440225035162, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1691177', 'n_tokens_mistral': 1024, 'n_tokens_neox': 961, 'n_words': 264}