Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var SHA1 = require("Crypto");
- class User {
- private id: number;
- private username: string;
- private password: string;
- constructor(username?: string, password?: string) {
- if (username && password) {
- this.username = username;
- this.password = password;
- }
- }
- Create(username, password, mail) {
- var user = Database.CreateUser(username, password, mail);
- return user;
- }
- Connect(crypted) {
- if (!crypted) {
- this.password = SHA1(this.password);
- }
- var users = Database.Search("users", { "username": this.username, "password": this.password });
- if (users.length >= 1) {
- if (users.length > 1) {
- console.log("Multiple Users Find, First Take");
- }
- this.id = users[0].id;
- } else {
- console.log("No User Find with username " + this.username);
- return 0;
- }
- }
- GetId() {
- return this.id;
- }
- GetUsername() {
- return this.username;
- }
- }
- module.exports = User;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement