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); }
public static UserModel FindByLogin(string login) { return(UserModel.FindByLogin(login)); }