def _simple_logged_in_auth(fail_message): logged_in = new_authz.auth_is_loggedin_user() if logged_in: return {'success': True} else: return {'success': False, 'msg': fail_message}
def flag(comment_id): if authz.auth_is_loggedin_user(): # Using the comment model rather than the update action because update action updates modified timestamp comment = comment_model.Comment.get(comment_id) if comment and not comment.flagged: comment.flagged = True model.Session.add(comment) model.Session.commit() email_notifications.flagged_comment_notification(comment)
def _valid_request_and_user(thread_or_comment_id): """ Check user logged in and perform simple validation of id provided in request :param thread_or_comment_id: :return: """ return False if not authz.auth_is_loggedin_user() \ or not id \ or _contains_invalid_chars(thread_or_comment_id) else True
def hdx_send_new_org_request(context, data_dict): logged_in = new_authz.auth_is_loggedin_user() if logged_in: return {'success': True} else: return { 'success': False, 'msg': _("You must be logged in to send a new organization request.") }
def get_snippet_actor(activity, detail): user = authz.auth_is_loggedin_user() if not user: if i18n.get_lang() == 'fr': return literal( '''<span class="actor">%s</span>''' % "L'équipe de données ouvertes de l'Ontario".decode('utf8')) else: return literal('''<span class="actor">Ontario's Open Data Team \ </span>''') else: return literal('''<span class="actor">%s</span>''' % (helpers.linked_user(activity['user_id'], 0, 30)))
def get_user_dataset_labels(self, user_obj): u""" If a user is logged in, it can view the private and public datasets Otherwise only the public datasets """ labels = super(ViewerpermissionsPlugin, self).get_user_dataset_labels(user_obj) label = "" # If user is logged in if auth_is_loggedin_user(): # Allow access to private datasets label = label + "private" # Always allow access to public datasets label = label + " public" labels = labels + [unicode(label)] # noqa: F821 return labels
def member_request_create(context, data_dict): """ Only allow to logged in users """ if not authz.auth_is_loggedin_user(): return {'success': False, 'msg': _('User is not logged in')} organization_id = None if not data_dict else data_dict.get( 'organization_id', None) if organization_id: member = get_user_member(organization_id) if member: return { 'success': False, 'msg': _('The user has already a pending request or an active membership' ) } return {'success': True}
def unflag(content_type, content_item_id, comment_id): """ Remove the 'flagged' attribute on a comment :param content_type: string 'dataset' or 'datarequest' :param content_item_id: string :param comment_id: string ID of the comment to unflag :return: """ context = {'model': model, 'user': c.user} # Using the comment model rather than the update action because update action updates modified timestamp comment = comment_model.Comment.get(comment_id) if not comment \ or not comment.flagged \ or not authz.auth_is_loggedin_user() \ or not helpers.user_can_manage_comments(content_type, content_item_id): abort(403) comment.flagged = False model.Session.add(comment) model.Session.commit() h.flash_success(_('Comment un-flagged')) data_dict = {'id': content_item_id} if content_type == 'datarequest': c.datarequest = get_action('show_datarequest')(context, data_dict) return h.redirect_to( str('/datarequest/comment/%s#comment_%s' % (content_item_id, comment_id))) else: c.pkg_dict = get_action('package_show')(context, data_dict) c.pkg = context['package'] return h.redirect_to( str('/dataset/%s#comment_%s' % (content_item_id, comment_id))) return helpers.render_content_template(content_type)
def _is_loggedinuser(self): return authz.auth_is_loggedin_user()
def _only_registered_user(): if not authz.auth_is_loggedin_user(): return {'success': False, 'msg': _('User is not logged in')} return {'success': True}
def orcid_authorize_auth(context, username): if not authz.auth_is_loggedin_user(): return {'success': False, 'msg': _('Not authorized to see this page')} return {'success': True}
def uploader(context, data_dict): # All registered users can access the Upload Dataset page return {'success': authz.auth_is_loggedin_user()}
def visualization_generator(context, data_dict): # All registered users can access the Visualization generator page return {'success': authz.auth_is_loggedin_user()}
def cue_generator(context, data_dict): # All registered users can access the Cue generator page return {'success': authz.auth_is_loggedin_user()}
def embedder(context, data_dict): # All registered users can access the Knowledge Embedder page return {'success': authz.auth_is_loggedin_user()}
def _only_registered_user(): if not authz.auth_is_loggedin_user(): return {'success': False, 'msg': _('User is not logged in')} return {'success': True}