コード例 #1
0
ファイル: clientService.cs プロジェクト: Mazoonn/Project-SWAP
        //Authentication
        //Input: loginDTO
        //Output: client
        public static client checkUserLogin(loginDTO body)
        {
            SwapDbConnection db   = new SwapDbConnection();
            client           user = db.clients.FirstOrDefault(x => x.email == body.email && x.platform == "local");

            if (user == null || !HashSalt.VerifyPassword(body.password, user.password, user.salt))
            {
                return(null);
            }
            user.last_login = DateTime.Now;
            db.SaveChanges();

            return(user);
        }
コード例 #2
0
ファイル: adminService.cs プロジェクト: Mazoonn/Project-SWAP
        //Generate new password
        //Input: id, password
        //Output: string result
        public static string NewPassword(string id, string password)
        {
            SwapDbConnection db     = new SwapDbConnection();
            client           client = db.clients.FirstOrDefault(c => c.client_id == id);
            HashSalt         hashSalt;

            if (client == null || client.platform != "local")
            {
                return("false");
            }
            if (HashSalt.VerifyPassword(password, client.password, client.salt))
            {
                return("same");
            }
            hashSalt        = HashSalt.GenerateSaltedHash(password);
            client.password = hashSalt.Hash;
            client.salt     = hashSalt.Salt;
            db.SaveChanges();
            return("ok");
        }