Ejemplo n.º 1
0
        public static UserModel FindOrCreateByEmailAndLogin(
            string email, string login, string password = null, UserModel referral = null
            )
        {
            password ??= Rand.RandomString();

            var user = UserModel.FindByEmail(email);

            var loginUser = UserModel.FindByLogin(login);

            var baseLogin  = login;
            int postfixNum = 0;

            while (loginUser != null)
            {
                postfixNum++;
                login     = $"{baseLogin}_{postfixNum}";
                loginUser = UserModel.FindByLogin(login);
            }

            user ??= Create(email, login, password);

            UserBadge.Create(user, "Early adopter");

            int tokenRegisterBonus = System.Convert.ToInt32(
                AppConfig.GetConfiguration("user:registration:token_bonus")
                );

            if (tokenRegisterBonus > 0)
            {
                UserBalance.Create(user, CurrencyType.GitComToken, tokenRegisterBonus);
                FundingTransaction.Create(
                    user, user.id, EntityType.User, null, tokenRegisterBonus, CurrencyType.GitComToken
                    );
            }

            if (referral != null)
            {
                UserReferralRepository.Create(user, referral);
            }

            return(user);
        }
Ejemplo n.º 2
0
 public static UserModel FindByEmail(string email)
 {
     return(UserModel.FindByEmail(email));
 }