Dotnet
Authentication and Authorization - Login
  •  

Solution - Login Request

PRO

I finished! On to the next chapter

Outline

Solution: Adding Login Request

In the Conduit.Models Project

Add a class called Login.cs with the following Properties
  • Email
    • Type: string
    • Visibility: public
  • Password
    • Type: string
    • Visibility: public
Add the following rules
  • Email
    • Required
    • Valid Email
    • Max Length 50
  • Password
    • Required

This is the code for the Login.cs file:

using System.ComponentModel.DataAnnotations;

namespace Conduit.Models.Requests
{
    public class Login
    {
        [Required(ErrorMessage = "Email is required.")]
        [EmailAddress(ErrorMessage = "Email address must be valid.")]
        [StringLength(50, ErrorMessage = "Email max length is 50 characters.")]
        public string Email { get; set; }

        [Required(ErrorMessage = "Password is required.")]
        public string Password { get; set; }
    }
}