除非授权或登录,否则如何将ckan重定向到外部URL [英] how to redirect ckan to external url unless authorized or signed in

查看:97
本文介绍了除非授权或登录,否则如何将ckan重定向到外部URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除非登录,否则如何将ckan重定向到外部URL?

How can i go about redirecting ckan to a external URL unless logged in?

我在下面的ckan / logic / auth / get.py中添加了以下代码如果context.get('auth_user_obj')不是None,则方法site_read

I added the following code below in ckan/logic/auth/get.py under the method site_read

if context.get('auth_user_obj') is not None:
    return {'success': True}
else:
    return {'success': False, 'msg': 'User not logged in. Pleaes authenticate with AD.'}

但是我只能说除非登录,否则每个页面上的权限都被拒绝。有没有办法我可以使其重定向到外部URL(如果没有)

But i only get as far as just saying permission denied on each page unless logged in. Is there a way i can make it just redirect to an external url if not signed in or authenticated?

谢谢!

推荐答案

实施 IRoutes接口

在before_map函数中检查用户是否已登录(如果未使用map.redirect则指向您的外部URL)。

In the before_map function check if a user is logged in, if not use map.redirect to your external URL.

这篇关于除非授权或登录,否则如何将ckan重定向到外部URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆