[Create(@"{code}", false, false)] //NOTE: this method doesn't requires auth!!! //NOTE: this method doesn't check payment!!! public AuthenticationTokenData AuthenticateMe(string userName, string password, string provider, string accessToken, string code) { bool viaEmail; var user = GetUser(userName, password, provider, accessToken, out viaEmail); try { SmsManager.ValidateSmsCode(user, code); var token = SecurityContext.AuthenticateMe(user.ID); MessageService.Send(Request, MessageAction.LoginSuccessViaApiSms); return(new AuthenticationTokenData { Token = token, Expires = new ApiDateTime(DateTime.UtcNow.AddYears(1)), Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(user.MobilePhone) }); } catch { MessageService.Send(Request, user.DisplayUserName(false), MessageAction.LoginFailViaApiSms, MessageTarget.Create(user.ID)); throw new AuthenticationException("User authentication failed"); } }
[Create(@"{code}", false)] //NOTE: this method doesn't requires auth!!! public AuthenticationTokenData AuthenticateMe(string userName, string password, string code) { var user = GetUser(userName, password); SmsManager.ValidateSmsCode(user, code); try { var token = SecurityContext.AuthenticateMe(user.ID); if (string.IsNullOrEmpty(token)) { throw new AuthenticationException("User authentication failed"); } MessageService.Send(_context, MessageAction.LoginSuccessViaApiSms); return(new AuthenticationTokenData { Token = token, Expires = new ApiDateTime(DateTime.UtcNow.AddYears(1)), Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(user.MobilePhone) }); } catch { MessageService.Send(_context, userName, MessageAction.LoginFailViaApi); throw; } }
[Create(@"setphone", false)] //NOTE: this method doesn't requires auth!!! public AuthenticationTokenData SaveMobilePhone(string userName, string password, string mobilePhone) { var user = GetUser(userName, password); mobilePhone = SmsManager.SaveMobilePhone(user, mobilePhone); return(new AuthenticationTokenData { Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(mobilePhone) }); }
[Create(@"sendsms", false)] //NOTE: this method doesn't requires auth!!! public AuthenticationTokenData SendSmsCode(string userName, string password) { var user = GetUser(userName, password); SmsManager.PutAuthCode(user, true); return(new AuthenticationTokenData { Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(user.MobilePhone) }); }
public object SendSmsCodeAgain() { var user = GetUser(); SmsManager.PutAuthCode(user, true); return (new { phoneNoise = SmsManager.BuildPhoneNoise(user.MobilePhone), confirm = true, }); }
[Create(@"sendsms", false, false)] //NOTE: this method doesn't requires auth!!! //NOTE: this method doesn't check payment!!! public AuthenticationTokenData SendSmsCode(string userName, string password, string provider, string accessToken) { bool viaEmail; var user = GetUser(userName, password, provider, accessToken, out viaEmail); SmsManager.PutAuthCode(user, true); return(new AuthenticationTokenData { Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(user.MobilePhone), Expires = new ApiDateTime(DateTime.UtcNow.Add(SmsKeyStorage.TrustInterval)) }); }
[Create(@"", false)] //NOTE: this method doesn't requires auth!!! public AuthenticationTokenData AuthenticateMe(string userName, string password) { userName.ThrowIfNull(new ArgumentException("userName empty", "userName")); password.ThrowIfNull(new ArgumentException("password empty", "password")); if (!StudioSmsNotificationSettings.IsVisibleSettings || !StudioSmsNotificationSettings.Enable) { try { var token = SecurityContext.AuthenticateMe(userName, password); if (string.IsNullOrEmpty(token)) { throw new AuthenticationException("User authentication failed"); } MessageService.Send(_context, MessageAction.LoginSuccessViaApi); return(new AuthenticationTokenData { Token = token, Expires = new ApiDateTime(DateTime.UtcNow.AddYears(1)) }); } catch { MessageService.Send(_context, userName, MessageAction.LoginFailViaApi); throw; } } var user = GetUser(userName, password); if (string.IsNullOrEmpty(user.MobilePhone) || user.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated) { return new AuthenticationTokenData { Sms = true } } ; SmsManager.PutAuthCode(user, false); return(new AuthenticationTokenData { Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(user.MobilePhone), Expires = new ApiDateTime(DateTime.UtcNow.AddMinutes(10)) }); }
[Create(@"", false, false)] //NOTE: this method doesn't requires auth!!! //NOTE: this method doesn't check payment!!! public AuthenticationTokenData AuthenticateMe(string userName, string password, string provider, string accessToken) { bool viaEmail; var user = GetUser(userName, password, provider, accessToken, out viaEmail); if (!StudioSmsNotificationSettings.IsVisibleSettings || !StudioSmsNotificationSettings.Enable) { try { var token = SecurityContext.AuthenticateMe(user.ID); MessageService.Send(Request, viaEmail ? MessageAction.LoginSuccessViaApi : MessageAction.LoginSuccessViaApiSocialAccount); return(new AuthenticationTokenData { Token = token, Expires = new ApiDateTime(DateTime.UtcNow.AddYears(1)) }); } catch { MessageService.Send(Request, user.DisplayUserName(false), viaEmail ? MessageAction.LoginFailViaApi : MessageAction.LoginFailViaApiSocialAccount); throw new AuthenticationException("User authentication failed"); } finally { SecurityContext.Logout(); } } if (string.IsNullOrEmpty(user.MobilePhone) || user.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated) { return new AuthenticationTokenData { Sms = true } } ; SmsManager.PutAuthCode(user, false); return(new AuthenticationTokenData { Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(user.MobilePhone), Expires = new ApiDateTime(DateTime.UtcNow.Add(SmsKeyStorage.TrustInterval)) }); }
[Create(@"setphone", false, false)] //NOTE: this method doesn't requires auth!!! //NOTE: this method doesn't check payment!!! public AuthenticationTokenData SaveMobilePhone(string userName, string password, string provider, string accessToken, string mobilePhone) { bool viaEmail; var user = GetUser(userName, password, provider, accessToken, out viaEmail); mobilePhone = SmsManager.SaveMobilePhone(user, mobilePhone); MessageService.Send(HttpContext.Current.Request, MessageAction.UserUpdatedMobileNumber, MessageTarget.Create(user.ID), user.DisplayUserName(false), mobilePhone); return(new AuthenticationTokenData { Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(mobilePhone), Expires = new ApiDateTime(DateTime.UtcNow.Add(SmsKeyStorage.TrustInterval)) }); }
public object SaveMobilePhone(string mobilePhone) { var user = GetUser(); mobilePhone = SmsManager.SaveMobilePhone(user, mobilePhone); var mustConfirm = StudioSmsNotificationSettings.Enable; return (new { phoneNoise = SmsManager.BuildPhoneNoise(mobilePhone), confirm = mustConfirm, RefererURL = mustConfirm ? string.Empty : GetRefererURL() }); }
public object SaveMobilePhone(string mobilePhone) { var user = GetUser(); mobilePhone = SmsManager.SaveMobilePhone(user, mobilePhone); MessageService.Send(HttpContext.Current.Request, MessageAction.UserUpdatedMobileNumber, MessageTarget.Create(user.ID), user.DisplayUserName(false), mobilePhone); var mustConfirm = StudioSmsNotificationSettings.Enable; return (new { phoneNoise = SmsManager.BuildPhoneNoise(mobilePhone), confirm = mustConfirm, RefererURL = mustConfirm ? string.Empty : GetRefererURL() }); }
[Create(@"{code}", false)] //NOTE: this method doesn't requires auth!!! public AuthenticationTokenData AuthenticateMe(string userName, string password, string code) { var user = GetUser(userName, password); SmsManager.ValidateSmsCode(user, code); var token = SecurityContext.AuthenticateMe(user.ID); if (string.IsNullOrEmpty(token)) { throw new AuthenticationException("User authentication failed"); } return(new AuthenticationTokenData { Token = token, Expires = new ApiDateTime(DateTime.UtcNow.AddYears(1)), Sms = true, PhoneNoise = SmsManager.BuildPhoneNoise(user.MobilePhone) }); }