def post(self): data = request.json if redis_store.get('user:'******'mobile_number']) and redis_store.get( data['mobile_number']).decode('utf-8') == str( data['otp']): user, errors = self.schema().load( json.loads( redis_store.get('user:'******'mobile_number']).decode('utf-8'))) if errors: return make_response(jsonify(errors), 400) try: db.session.add(user) db.session.commit() except (IntegrityError, InvalidRequestError) as e: print(e) db.session.rollback() return make_response(jsonify({}), 400) expires = timedelta(days=365) return make_response( jsonify({ 'id': user.id, 'user': UserSchema().dump(user, only=('id', 'email', 'first_name', 'last_name', 'roles', 'business_name')), 'authentication_token': create_access_token(identity=user.id, expires_delta=expires) }), 200) else: return make_response(jsonify({'meta': {'code': 403}}), 403)
def post(self): data = request.json user = self.model.query.filter( self.model.mobile_number == data['mobile_number']).first() if user and redis_store.get( data['mobile_number']).decode('utf-8') == data['otp']: utu = UserToUser() utu.business_owner_id = current_user.id utu.customer_id = user.id db.session.add(utu) db.session.commit() return make_response( jsonify({ 'id': user.id, 'first_name': user.first_name }), 200) else: return make_response(jsonify({'meta': {'code': 403}}), 403)