Example #1
0
        public void PutAuthCode(UserInfo user, bool again)
        {
            if (user == null || Equals(user, Constants.LostUser))
            {
                throw new Exception(Resource.ErrorUserNotFound);
            }

            if (!StudioSmsNotificationSettingsHelper.IsVisibleSettings() || !StudioSmsNotificationSettingsHelper.Enable)
            {
                throw new MethodAccessException();
            }

            var mobilePhone = SmsSender.GetPhoneValueDigits(user.MobilePhone);

            if (SmsKeyStorage.ExistsKey(mobilePhone) && !again)
            {
                return;
            }

            if (!SmsKeyStorage.GenerateKey(mobilePhone, out var key))
            {
                throw new Exception(Resource.SmsTooMuchError);
            }
            if (SmsSender.SendSMS(mobilePhone, string.Format(Resource.SmsAuthenticationMessageToUser, key)))
            {
                TenantManager.SetTenantQuotaRow(new TenantQuotaRow {
                    Tenant = TenantManager.GetCurrentTenant().TenantId, Path = "/sms", Counter = 1
                }, true);
            }
        }
Example #2
0
        public static void PutAuthCode(UserInfo user, bool again)
        {
            if (user == null || Equals(user, Constants.LostUser))
            {
                throw new Exception(Resource.ErrorUserNotFound);
            }
            var mobilePhone = GetPhoneValueDigits(user.MobilePhone);

            if (SmsKeyStorage.ExistsKey(mobilePhone) && !again)
            {
                return;
            }

            var key = SmsKeyStorage.GenerateKey(mobilePhone);

            SmsSender.SendSMS(mobilePhone, string.Format(Resource.SmsAuthenticationMessageToUser, key));
        }