コード例 #1
0
ファイル: security.py プロジェクト: Edin93/old_Mynd
def authenticate(username, password):
    user = storage.get_user_by_username(username)
    if user and safe_str_cmp(user.password.encode('utf-8'),
                             hashlib.md5(password.encode()).hexdigest()):
        log = Log()
        log.user_id = user.id
        log.session_start = datetime.utcnow()
        log.save()
        return user
コード例 #2
0
ファイル: test.py プロジェクト: Edin93/old_Mynd
p1.user_id = u1.id
p1.description = 'this is description'
p1.save()
print(p1)
c1 = Comment()
c1.text = 'this is the first comment ever'
c1.user_id = u1.id
c1.post_id = p1.id
c1.save()
print(c1)
lk1 = PostLike()
lk1.post_id = p1.id
lk1.user_id = u1.id
lk1.save()
print(lk1)
lg = Log()
lg.user_id = u1.id
lg.save()
print(lg)
t1 = Topic()
t1.title = 'hotel'
t1.description = 'we love hotels'
t1.posts.append(p1)
t1.users.append(u1)
t1.save()
print(t1)
print("THIS IS U1.TOPICS!!")
print(u1.topics)
print("THIS IS U1.posts!!")
print(u1.posts)