BetterFinds
Public Member Functions | Properties | Static Private Member Functions | Private Attributes | List of all members
BetterFinds.Pages.RegisterModel Class Reference

Model for the Register page. More...

Inheritance diagram for BetterFinds.Pages.RegisterModel:
Inheritance graph
[legend]
Collaboration diagram for BetterFinds.Pages.RegisterModel:
Collaboration graph
[legend]

Public Member Functions

 RegisterModel (IConfiguration configuration)
 Initializes a new instance of the RegisterModel class. More...
 
IActionResult OnGet ()
 Redirects authenticated user to index page, otherwise loads page. More...
 
IActionResult OnPost ()
 Creates a new account if all requirements are met. More...
 

Properties

string FullName = "" [get, set]
 The full name of the user. More...
 
string Username = "" [get, set]
 The username of the user. More...
 
string Email = "" [get, set]
 The email of the user. More...
 
string Password = "" [get, set]
 The password of the user. More...
 
string ConfirmPassword = "" [get, set]
 The password confirmation of the user. More...
 
string? ProfilePic [get, set]
 The profile picture of the user. More...
 
bool OptNewsletter = false [get, set]
 Whether the user wants to receive the newsletter. More...
 

Static Private Member Functions

static partial Regex RegexUsername ()
 Returns a regex that matches a username. More...
 
static partial Regex RegexFullName ()
 Returns a regex that matches a full name. More...
 

Private Attributes

readonly IConfiguration configuration
 The IConfiguration instance. More...
 

Detailed Description

Model for the Register page.

Constructor & Destructor Documentation

◆ RegisterModel()

BetterFinds.Pages.RegisterModel.RegisterModel ( IConfiguration  configuration)

Initializes a new instance of the RegisterModel class.

Parameters
configurationThe IConfiguration instance.

Member Function Documentation

◆ OnGet()

IActionResult BetterFinds.Pages.RegisterModel.OnGet ( )
inline

Redirects authenticated user to index page, otherwise loads page.

Checks if the user is logged in using the current session, if any. If the user is logged in redirects him to the index page. Otherwise, loads the register page.

Returns
A task that represents the page redirection or loading.

◆ OnPost()

IActionResult BetterFinds.Pages.RegisterModel.OnPost ( )
inline

Creates a new account if all requirements are met.

  • Username must be unique, and between 3 and 32 alphanumeric characters.
  • Password must be between 8 and 64 characters.
  • Password must match ConfirmPassword.
  • Email must be unique, and between 5 and 320 characters.
  • Full name must be between 3 and 64 alphabetical characters and spaces.
  • Profile picture must be 256 characters or fewer.
  • OptNewsletter is an optional checkbox.

If the requirements are met, the user is added to the database and redirected to the login page, with a success message and the username pre-filled. Otherwise, the user is redirected to the register page with an error message.

Returns
A task that represents the creation of an account.

◆ RegexFullName()

static partial Regex BetterFinds.Pages.RegisterModel.RegexFullName ( )
staticprivate

Returns a regex that matches a full name.

A full name contains only alphabetical characters and spaces.

Returns
A regex that matches a full name.

◆ RegexUsername()

static partial Regex BetterFinds.Pages.RegisterModel.RegexUsername ( )
staticprivate

Returns a regex that matches a username.

A username contains only alphanumeric characters.

Returns
A regex that matches a username.

Member Data Documentation

◆ configuration

readonly IConfiguration BetterFinds.Pages.RegisterModel.configuration
private

The IConfiguration instance.

Property Documentation

◆ ConfirmPassword

string BetterFinds.Pages.RegisterModel.ConfirmPassword = ""
getset

The password confirmation of the user.

◆ Email

string BetterFinds.Pages.RegisterModel.Email = ""
getset

The email of the user.

◆ FullName

string BetterFinds.Pages.RegisterModel.FullName = ""
getset

The full name of the user.

◆ OptNewsletter

bool BetterFinds.Pages.RegisterModel.OptNewsletter = false
getset

Whether the user wants to receive the newsletter.

◆ Password

string BetterFinds.Pages.RegisterModel.Password = ""
getset

The password of the user.

◆ ProfilePic

string? BetterFinds.Pages.RegisterModel.ProfilePic
getset

The profile picture of the user.

◆ Username

string BetterFinds.Pages.RegisterModel.Username = ""
getset

The username of the user.


The documentation for this class was generated from the following file: