Skip to content

Commit

Permalink
new hash support
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 10, 2018
1 parent 0f4c088 commit 6956daa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/appier_extras/parts/admin/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,12 @@ def is_snapshot(cls):
return False

@classmethod
def secret_g(cls):
def secret_g(cls, hash = None):
hash = hash or hashlib.sha1
token = "".join(random.choice(RANDOM_RANGE) for _index in range(32))
token_bytes = appier.legacy.bytes(token)
url_sha1 = hashlib.sha1(token_bytes)
return url_sha1.hexdigest()
token_hash = hash(token_bytes)
return token_hash.hexdigest()

@classmethod
def build_index_g(cls, *args, **kwargs):
Expand Down Expand Up @@ -617,9 +618,9 @@ def send_email(self, *args, **kwargs):
kwargs["own"] = kwargs.pop("own", self)
return cls.send_email_g(owner, *args, **kwargs)

def secret(self):
def secret(self, hash = None):
cls = self.__class__
return cls.secret_g()
return cls.secret_g(hash = hash)

@appier.operation(name = "Enable")
def op_enable_s(self):
Expand Down

0 comments on commit 6956daa

Please sign in to comment.