Advertisement
LYSoft

Untitled

May 12th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. public User Login() // returns an instance of its own class
  2.         {
  3.             var us = ie.users.FirstOrDefault(u => u.emailaddress == emailaddress);
  4.  
  5.             User user = new User();
  6.  
  7.             if (us == null)
  8.             {
  9.                 throw new Exception("Invalid email address and/or password.");
  10.             }
  11.  
  12.             if (Hashing.ValidatePassword(password, us.password))
  13.             {
  14.                 user.userid = us.userid;
  15.                 user.storeid = us.storeid;
  16.                 user.role = us.role;
  17.             }
  18.             else
  19.             {
  20.                 throw new ValidationException("Invalid email address and/or password.");
  21.             }
  22.  
  23.             return user;
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement