Update 07082021
This commit is contained in:
34
WebFormApp/Account/AddPhoneNumber.aspx.cs
Normal file
34
WebFormApp/Account/AddPhoneNumber.aspx.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.Owin;
|
||||
using System.Threading.Tasks;
|
||||
using WebFormApp.Models;
|
||||
|
||||
namespace WebFormApp.Account
|
||||
{
|
||||
public partial class AddPhoneNumber : System.Web.UI.Page
|
||||
{
|
||||
protected void PhoneNumber_Click(object sender, EventArgs e)
|
||||
{
|
||||
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
|
||||
var code = manager.GenerateChangePhoneNumberToken(User.Identity.GetUserId(), PhoneNumber.Text);
|
||||
if (manager.SmsService != null)
|
||||
{
|
||||
var message = new IdentityMessage
|
||||
{
|
||||
Destination = PhoneNumber.Text,
|
||||
Body = "Ihr Sicherheitscode lautet " + code
|
||||
};
|
||||
|
||||
manager.SmsService.Send(message);
|
||||
}
|
||||
|
||||
Response.Redirect("/Account/VerifyPhoneNumber?PhoneNumber=" + HttpUtility.UrlEncode(PhoneNumber.Text));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user