Advertisement
Guest User

Untitled

a guest
Aug 31st, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. export class User {
  2.  
  3. private _username;
  4. private passwordHash;
  5.  
  6. constructor(name: string, password: string) {
  7. this._username = name;
  8. this.password = password;
  9. }
  10.  
  11. get username() {
  12. return this._username;
  13. }
  14.  
  15. set password(password: string) {
  16. this.passwordHash = this.securePassword(password);
  17. }
  18.  
  19. validatePassword(password) {
  20. console.log('::: Validating password :::');
  21. return this.passwordHash == this.securePassword(password);
  22. }
  23.  
  24. private securePassword(password :string) {
  25. return atob(password);
  26. }
  27.  
  28. getSecureData(password: string) {
  29. if (this.validatePassword(password)) {
  30. return {secure: true};
  31. }
  32. return null;
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement