Skip to content

Commit

Permalink
fix encoding of password and remove double hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
alexaorrico committed Dec 23, 2017
1 parent 691c0f1 commit 988a315
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions models/user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python3
""" holds class User"""
from base64 import b64encode
import hashlib
import models
from models.base_model import BaseModel, Base
Expand Down Expand Up @@ -36,9 +35,6 @@ class User(BaseModel, Base):

def __init__(self, *args, **kwargs):
"""initializes user"""
if 'password' in kwargs:
pwd = hashlib.md5(b64encode(kwargs['password'].encode('ascii')))
kwargs['password'] = pwd.hexdigest()
super().__init__(*args, **kwargs)

@property
Expand All @@ -48,5 +44,4 @@ def password(self):
@password.setter
def password(self, pwd):
"""hashing password values"""
self._password = hashlib.md5(b64encode(pwd
.encode('ascii'))).hexdigest()
self._password = hashlib.md5(pwd.encode()).hexdigest()

0 comments on commit 988a315

Please sign in to comment.