summaryrefslogtreecommitdiffstats
path: root/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models
diff options
context:
space:
mode:
authorDavid Christiansen <coding@davedoes.net>2015-01-05 21:29:48 +0000
committerDavid Christiansen <coding@davedoes.net>2015-01-05 21:29:48 +0000
commit5fde84cfe2967d203c8bc183708394d95bb52c36 (patch)
treeb082a01743f2d20ce80dddcc4a99f88f0c49e1c4 /samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models
parentf840b593c345265ebcfd6c1cf5b57ab6d948f92c (diff)
downloadDotNetOpenAuth-5fde84cfe2967d203c8bc183708394d95bb52c36.zip
DotNetOpenAuth-5fde84cfe2967d203c8bc183708394d95bb52c36.tar.gz
DotNetOpenAuth-5fde84cfe2967d203c8bc183708394d95bb52c36.tar.bz2
Straight forward OpenID Connect RP example
Diffstat (limited to 'samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models')
-rw-r--r--samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/AccountViewModels.cs112
-rw-r--r--samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/IdentityModels.cs33
-rw-r--r--samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/ManageViewModels.cs86
3 files changed, 231 insertions, 0 deletions
diff --git a/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/AccountViewModels.cs b/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/AccountViewModels.cs
new file mode 100644
index 0000000..6f6a07a
--- /dev/null
+++ b/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/AccountViewModels.cs
@@ -0,0 +1,112 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+
+namespace DotNetOpenAuth.Samples.OpenIDConnectRP.Models
+{
+ public class ExternalLoginConfirmationViewModel
+ {
+ [Required]
+ [Display(Name = "Email")]
+ public string Email { get; set; }
+ }
+
+ public class ExternalLoginListViewModel
+ {
+ public string ReturnUrl { get; set; }
+ }
+
+ public class SendCodeViewModel
+ {
+ public string SelectedProvider { get; set; }
+ public ICollection<System.Web.Mvc.SelectListItem> Providers { get; set; }
+ public string ReturnUrl { get; set; }
+ public bool RememberMe { get; set; }
+ }
+
+ public class VerifyCodeViewModel
+ {
+ [Required]
+ public string Provider { get; set; }
+
+ [Required]
+ [Display(Name = "Code")]
+ public string Code { get; set; }
+ public string ReturnUrl { get; set; }
+
+ [Display(Name = "Remember this browser?")]
+ public bool RememberBrowser { get; set; }
+
+ public bool RememberMe { get; set; }
+ }
+
+ public class ForgotViewModel
+ {
+ [Required]
+ [Display(Name = "Email")]
+ public string Email { get; set; }
+ }
+
+ public class LoginViewModel
+ {
+ [Required]
+ [Display(Name = "Email")]
+ [EmailAddress]
+ public string Email { get; set; }
+
+ [Required]
+ [DataType(DataType.Password)]
+ [Display(Name = "Password")]
+ public string Password { get; set; }
+
+ [Display(Name = "Remember me?")]
+ public bool RememberMe { get; set; }
+ }
+
+ public class RegisterViewModel
+ {
+ [Required]
+ [EmailAddress]
+ [Display(Name = "Email")]
+ public string Email { get; set; }
+
+ [Required]
+ [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
+ [DataType(DataType.Password)]
+ [Display(Name = "Password")]
+ public string Password { get; set; }
+
+ [DataType(DataType.Password)]
+ [Display(Name = "Confirm password")]
+ [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
+ public string ConfirmPassword { get; set; }
+ }
+
+ public class ResetPasswordViewModel
+ {
+ [Required]
+ [EmailAddress]
+ [Display(Name = "Email")]
+ public string Email { get; set; }
+
+ [Required]
+ [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
+ [DataType(DataType.Password)]
+ [Display(Name = "Password")]
+ public string Password { get; set; }
+
+ [DataType(DataType.Password)]
+ [Display(Name = "Confirm password")]
+ [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
+ public string ConfirmPassword { get; set; }
+
+ public string Code { get; set; }
+ }
+
+ public class ForgotPasswordViewModel
+ {
+ [Required]
+ [EmailAddress]
+ [Display(Name = "Email")]
+ public string Email { get; set; }
+ }
+}
diff --git a/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/IdentityModels.cs b/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/IdentityModels.cs
new file mode 100644
index 0000000..12bd3dc
--- /dev/null
+++ b/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/IdentityModels.cs
@@ -0,0 +1,33 @@
+using System.Data.Entity;
+using System.Security.Claims;
+using System.Threading.Tasks;
+using Microsoft.AspNet.Identity;
+using Microsoft.AspNet.Identity.EntityFramework;
+
+namespace DotNetOpenAuth.Samples.OpenIDConnectRP.Models
+{
+ // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
+ public class ApplicationUser : IdentityUser
+ {
+ public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
+ {
+ // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
+ var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
+ // Add custom user claims here
+ return userIdentity;
+ }
+ }
+
+ public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
+ {
+ public ApplicationDbContext()
+ : base("DefaultConnection", throwIfV1Schema: false)
+ {
+ }
+
+ public static ApplicationDbContext Create()
+ {
+ return new ApplicationDbContext();
+ }
+ }
+} \ No newline at end of file
diff --git a/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/ManageViewModels.cs b/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/ManageViewModels.cs
new file mode 100644
index 0000000..1128f0b
--- /dev/null
+++ b/samples/DotNetOpenAuth.Samples.OpenIDConnectRP/Models/ManageViewModels.cs
@@ -0,0 +1,86 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using Microsoft.AspNet.Identity;
+using Microsoft.Owin.Security;
+
+namespace DotNetOpenAuth.Samples.OpenIDConnectRP.Models
+{
+ public class IndexViewModel
+ {
+ public bool HasPassword { get; set; }
+ public IList<UserLoginInfo> Logins { get; set; }
+ public string PhoneNumber { get; set; }
+ public bool TwoFactor { get; set; }
+ public bool BrowserRemembered { get; set; }
+ }
+
+ public class ManageLoginsViewModel
+ {
+ public IList<UserLoginInfo> CurrentLogins { get; set; }
+ public IList<AuthenticationDescription> OtherLogins { get; set; }
+ }
+
+ public class FactorViewModel
+ {
+ public string Purpose { get; set; }
+ }
+
+ public class SetPasswordViewModel
+ {
+ [Required]
+ [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
+ [DataType(DataType.Password)]
+ [Display(Name = "New password")]
+ public string NewPassword { get; set; }
+
+ [DataType(DataType.Password)]
+ [Display(Name = "Confirm new password")]
+ [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
+ public string ConfirmPassword { get; set; }
+ }
+
+ public class ChangePasswordViewModel
+ {
+ [Required]
+ [DataType(DataType.Password)]
+ [Display(Name = "Current password")]
+ public string OldPassword { get; set; }
+
+ [Required]
+ [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
+ [DataType(DataType.Password)]
+ [Display(Name = "New password")]
+ public string NewPassword { get; set; }
+
+ [DataType(DataType.Password)]
+ [Display(Name = "Confirm new password")]
+ [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
+ public string ConfirmPassword { get; set; }
+ }
+
+ public class AddPhoneNumberViewModel
+ {
+ [Required]
+ [Phone]
+ [Display(Name = "Phone Number")]
+ public string Number { get; set; }
+ }
+
+ public class VerifyPhoneNumberViewModel
+ {
+ [Required]
+ [Display(Name = "Code")]
+ public string Code { get; set; }
+
+ [Required]
+ [Phone]
+ [Display(Name = "Phone Number")]
+ public string PhoneNumber { get; set; }
+ }
+
+ public class ConfigureTwoFactorViewModel
+ {
+ public string SelectedProvider { get; set; }
+ public ICollection<System.Web.Mvc.SelectListItem> Providers { get; set; }
+ }
+} \ No newline at end of file