def create_password_reset(cls, email, valid_for=3600) -> str:
        """
        Create a password reset request in the user_password_resets
        database table. Hashed code gets stored in the database.
        Returns unhashed reset code
        """
        user = cls.where_email(email)
        if user is None:
            return None
        PasswordResetModel.delete_where_user_id(user.id)
        token = JWT().create_token({
            'code': Security.random_string(5),  # make unique
            'user_id': user.id},
            token_valid_for=valid_for)
        code = Security.generate_uuid(1) + "-" + Security.random_string(5)
        password_reset_model = PasswordResetModel()
        password_reset_model.token = token
        password_reset_model.code = code
        password_reset_model.user_id = user.id
        password_reset_model.save()
        return code
def create_password_reset ( cls , email , valid_for = 3600 ) -> str : user = cls . where_email ( email ) if user is None : return None PasswordResetModel . delete_where_user_id ( user . id ) token = JWT ( ) . create_token ( { 'code' : Security . random_string ( 5 ) , 'user_id' : user . id } , token_valid_for = valid_for ) code = Security . generate_uuid ( 1 ) + "-" + Security . random_string ( 5 ) password_reset_model = PasswordResetModel ( ) password_reset_model . token = token password_reset_model . code = code password_reset_model . user_id = user . id password_reset_model . save ( ) return code
Create a password reset request in the user_password_resets
        database table. Hashed code gets stored in the database.
        Returns unhashed reset code