Skip to content
This repository has been archived by the owner on Jun 21, 2019. It is now read-only.

Commit

Permalink
rref #5367
Browse files Browse the repository at this point in the history
  • Loading branch information
evrenesat committed Jun 22, 2016
1 parent a0df6f7 commit 6a5e34d
Showing 1 changed file with 4 additions and 51 deletions.
55 changes: 4 additions & 51 deletions ulakbus/models/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from passlib.hash import pbkdf2_sha512
from pyoko import LinkProxy
from pyoko.conf import settings
from pyoko.lib.utils import lazy_property

from zengine.auth.permissions import get_all_permissions
from zengine.dispatch.dispatcher import receiver
Expand Down Expand Up @@ -51,59 +52,11 @@ class Meta:
verbose_name_plural = "Kullanıcılar"
search_fields = ['username', 'name', 'surname']

def get_avatar_url(self):
"""
Bu metot kullanıcıya ait avatar url'ini üretir.
Returns:
str: kullanıcı avatar url
"""
return "%s%s" % (settings.S3_PUBLIC_URL, self.avatar)

def __unicode__(self):
return "User %s" % self.username

def set_password(self, raw_password):
"""
Kullanıcı şifresini encrypt ederek set eder.
Args:
raw_password (str)
"""
self.password = pbkdf2_sha512.encrypt(raw_password, rounds=10000,
salt_size=10)

def pre_save(self):
""" encrypt password if not already encrypted """
if self.password and not self.password.startswith('$pbkdf2'):
self.set_password(self.password)
@lazy_property
def full_name(self):
return "%s %s" % (self.name, self.surname)

def check_password(self, raw_password):
"""
Verilen encrypt edilmemiş şifreyle kullanıcıya ait encrypt
edilmiş şifreyi karşılaştırır.
Args:
raw_password (str)

Returns:
bool: Değerler aynı olması halinde True, değilse False
döner.
"""
return pbkdf2_sha512.verify(raw_password, self.password)

def get_role(self, role_id):
"""
Kullanıcıya ait Role nesnesini getirir.
Args:
role_id (int)
Returns:
dict: Role nesnesi
"""
return self.role_set.node_dict[role_id]

# def send_message(self, title, message, sender=None):
# from zengine.messaging import Notify
Expand Down

0 comments on commit 6a5e34d

Please sign in to comment.