MCPcopy
hub / github.com/diffgram/diffgram / Signup_code

Class Signup_code

shared/database/user.py:364–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362
363# TODO rename to Auth_code to support verify, reset, etc.
364class Signup_code(Base):
365 """
366
367 """
368 __tablename__ = 'signup_code'
369 id = Column(Integer, primary_key = True)
370
371 type = Column(String())
372 # ['verify_signup', 'invite_by_trainer_org', 'add_to_project', 'add_to_exam']
373
374 created_time_int = Column(Integer) # integer time vs datetime...
375
376 # TODO link to user directly when possible?
377
378 created_time = Column(DateTime, default = datetime.datetime.utcnow)
379 redeemed_time = Column(DateTime)
380
381 code = Column(String(100))
382 is_available = Column(Boolean, default = True)
383
384 email_sent_to = Column(String(100))
385 project_string_id = Column(String(100))
386 permission_level = Column(String())
387
388 # TODO this is awkward here
389 # Why not part of init?
390 # Also maybe rename to "hash" ? is code confusing?
391 def new_code(self, session):
392 salt = hashing_functions.make_salt()
393 seed = "2uji9890"
394 self.code = hashing_functions.hashlib.sha256(
395 (self.email_sent_to + seed + salt).encode('utf-8')).hexdigest()
396 return self.code
397
398 @staticmethod
399 def get_latest_code(session, email):
400 code = session.query(Signup_code).filter(
401 Signup_code.email_sent_to == email,
402 Signup_code.is_available == True
403 ).first()
404 return code
405
406
407class UserbaseProject(Base):

Callers 2

newFunction · 0.90
newMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected