def _create_fake_account(self): self.admin = AdminModel(id=self.admin_id, pw=self.encrypted_pw, name=self.admin_name).save() self.student = StudentModel(id=self.student_id, pw=self.encrypted_pw, name=self.student_name, number=self.student_number).save()
def _create_fake_accounts(self): AdminModel( id=self.admin_id, pw=self.hashed_pw, name='fake' ).save() StudentModel( id=self.student_id, pw=self.hashed_pw, name='fake', number=1111 ).save()
def _create_fake_account(self): pw = hexlify( pbkdf2_hmac('sha256', b'pw', app.secret_key.encode(), 100000)).decode() AdminModel(signup_time=datetime.now, id='admin', pw=pw, name='fake_admin').save() StudentModel(signup_time=datetime.now, id='student', pw=pw, name='fake_student', number=1111).save()
def post(self): payload = request.json if StudentModel.objects.filter( Q(username=payload['username']) or Q(student_id=payload['studentId'])).first(): return {}, 409 else: try: student = StudentModel( username=payload['username'], password=payload['password'], name=payload['name'], student_id=payload['studentId'], birth=datetime.strptime(payload['birth'], "%Y-%m-%d").date(), profile_image=payload['profileImage']).save() return { 'access': AccessTokenModel.create_access_token(student), 'refresh': RefreshTokenModel.create_refresh_token(student) }, 201 except NotUniqueError: return {}, 409
def post(self): payload = request.json uuid = payload['uuid'] id = payload['id'] password = payload['password'] if StudentModel.objects(id=id): abort(409) signup_waiting = SignupWaitingModel.objects(uuid=uuid).first() if not signup_waiting: return Response('', 204) StudentModel( id=id, pw=self.encrypt_password(password), name=signup_waiting.name, number=signup_waiting.number ).save() signup_waiting.delete() return Response('', 201)