Python google.appengine.api.users.create_logout_url() Examples
The following are 30
code examples of google.appengine.api.users.create_logout_url().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
google.appengine.api.users
, or try the search function
.
Example #1
Source File: base.py From personfinder with Apache License 2.0 | 6 votes |
def setup(self, request, *args, **kwargs): """See docs on BaseView.setup.""" # pylint: disable=attribute-defined-outside-init super(AdminBaseView, self).setup(request, *args, **kwargs) self.params.read_values(post_params={'xsrf_token': utils.strip}) self.env.show_logo = True self.env.enable_javascript = True self.env.user = users.get_current_user() self.env.user_admin_permission = self._get_user_admin_permission() self.env.logout_url = users.create_logout_url(self.build_absolute_uri()) self.env.all_repo_options = [ utils.Struct( repo=repo, url=self.build_absolute_path('/%s/admin' % repo)) for repo in sorted(model.Repo.list()) ] self.xsrf_tool = utils.XsrfTool()
Example #2
Source File: appengine_main.py From golinks with MIT License | 6 votes |
def get(self, param): user = users.get_current_user() if not user: self.redirect(users.create_login_url(self.request.path)) return sign_out_link = users.create_logout_url('/') is_admin = users.is_current_user_admin() if param == "all" and is_admin: links = Link.query().fetch() else: links = Link.query(Link.owner_id == user.user_id()).fetch() context = { "links": links, "is_admin": is_admin, "sign_out_link": sign_out_link, "fqdn": config.GOLINKS_FQDN, "hostname": config.GOLINKS_HOSTNAME } self.response.write(render("template/list.html", context))
Example #3
Source File: frontend_views.py From googleapps-message-recall with Apache License 2.0 | 6 votes |
def _WriteTemplate(self, template_file, **kwargs): """Common method to write from a template. Args: template_file: String name of a file that exists within the template folder. For subdirectories the name may be 'sub/file'. **kwargs: A dictionary of key-value pairs that will be available within the template. """ kwargs['tpl_logout_url'] = users.create_logout_url('/') kwargs['tpl_user_name'] = _SafelyGetCurrentUserEmail() if '.' not in template_file: template_file = '%s.html' % template_file self.response.headers['X-Frame-Options'] = 'DENY' # Prevent clickjacking. self.response.write( self._jinja_env.get_template(template_file).render(kwargs))
Example #4
Source File: main.py From datastore-ndb-python with Apache License 2.0 | 6 votes |
def get(self): user = users.get_current_user() if not user: self.redirect(users.create_login_url('/account')) return email = user.email() action = 'Create' account, nickname = yield (get_account(user.user_id()), get_nickname(user.user_id())) if account is not None: action = 'Update' if account: proposed_nickname = account.nickname or account.email else: proposed_nickname = email values = {'email': email, 'nickname': nickname, 'proposed_nickname': proposed_nickname, 'login': users.create_login_url('/home'), 'logout': users.create_logout_url('/home'), 'action': action, } self.response.out.write(ACCOUNT_PAGE % values)
Example #5
Source File: helloworld.py From cloud-playground with Apache License 2.0 | 6 votes |
def get(self): # pylint:disable-msg=invalid-name """Handle GET requests.""" guestbook_name = self.request.get('guestbook_name') greetings_query = Greeting.all().ancestor( _GuestbookKey(guestbook_name)).order('-date') greetings = greetings_query.fetch(10) if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Login' template_values = { 'greetings': greetings, 'url': url, 'url_linktext': url_linktext, } template = jinja_environment.get_template('index.html') self.response.out.write(template.render(template_values))
Example #6
Source File: main.py From python-docs-samples with Apache License 2.0 | 6 votes |
def index(): user = users.get_current_user() if user: logged_in = True nickname = user.nickname() logout_url = users.create_logout_url('/') login_url = None else: logged_in = False nickname = None logout_url = None login_url = users.create_login_url('/') template_values = { 'logged_in': logged_in, 'nickname': nickname, 'logout_url': logout_url, 'login_url': login_url, } return flask.render_template('index.html', **template_values) # Fake status
Example #7
Source File: blogapp.py From python-for-android with Apache License 2.0 | 6 votes |
def get(self): template_values = { 'sign_out': users.create_logout_url('/') } # See if we have an auth token for this user. token = get_auth_token(self.request) if token is None: template_values['auth_url'] = gdata.gauth.generate_auth_sub_url( self.request.url, ['http://www.blogger.com/feeds/']) path = os.path.join(os.path.dirname(__file__), 'auth_required.html') self.response.out.write(template.render(path, template_values)) return elif token == False: self.response.out.write( '<html><body><a href="%s">You must sign in first</a>' '</body></html>' % users.create_login_url('/blogs')) return client = gdata.blogger.client.BloggerClient() feed = client.get_blogs(auth_token=token) template_values['feed'] = feed path = os.path.join(os.path.dirname(__file__), 'list_blogs.html') self.response.out.write(template.render(path, template_values))
Example #8
Source File: update_credentials_view.py From googleads-python-lib with Apache License 2.0 | 6 votes |
def post(self): """Handle post request.""" template_values = { 'back_url': '/showCredentials', 'back_msg': 'View Credentials', 'logout_url': users.create_logout_url('/'), 'user_nickname': users.get_current_user().nickname() } try: UpdateUserCredentials(self.request.get('client_id'), self.request.get('client_secret'), self.request.get('refresh_token'), self.request.get('adwords_manager_cid'), self.request.get('dev_token')) self.redirect('/showCredentials') except Exception as e: template_values['error'] = str(e) # Use template to write output to the page. path = os.path.join(os.path.dirname(__file__), '../templates/base_template.html') self.response.out.write(template.render(path, template_values))
Example #9
Source File: handler.py From luci-py with Apache License 2.0 | 5 votes |
def create_logout_url(self, dest_url): """When cookie auth is used returns URL to redirect user to logout.""" return self._get_users_api().create_logout_url(self.request, dest_url)
Example #10
Source File: handler.py From luci-py with Apache License 2.0 | 5 votes |
def create_logout_url(request, dest_url): # pylint: disable=unused-argument return users.create_logout_url(dest_url) # See AuthenticatingHandler._get_users_api().
Example #11
Source File: handler.py From luci-py with Apache License 2.0 | 5 votes |
def create_logout_url(self, dest_url): """When cookie auth is used returns URL to redirect user to logout.""" return self._get_users_api().create_logout_url(self.request, dest_url)
Example #12
Source File: handler.py From luci-py with Apache License 2.0 | 5 votes |
def create_logout_url(request, dest_url): # pylint: disable=unused-argument return users.create_logout_url(dest_url) # See AuthenticatingHandler._get_users_api().
Example #13
Source File: handler.py From luci-py with Apache License 2.0 | 5 votes |
def create_logout_url(self, dest_url): """When cookie auth is used returns URL to redirect user to logout.""" return self._get_users_api().create_logout_url(self.request, dest_url)
Example #14
Source File: handler.py From luci-py with Apache License 2.0 | 5 votes |
def create_logout_url(request, dest_url): # pylint: disable=unused-argument return users.create_logout_url(dest_url) # See AuthenticatingHandler._get_users_api().
Example #15
Source File: main.py From cas-eval with Apache License 2.0 | 5 votes |
def main(): user = users.get_current_user() if not user: return flask.redirect(users.create_login_url(flask.request.path)) if flask.request.method == 'POST': util.csrf_protect() tab_ids = flask.request.values.getlist('tab_id') keys = [ndb.Key(Session, tab_id) for tab_id in tab_ids] if 'delete' in flask.request.values: if not all(s and s.user_id == user.user_id() for s in ndb.get_multi(keys)): return 'Not authorized to delete some sessions', 403 ndb.delete_multi(keys) elif 'share' in flask.request.values: for key in keys: session = key.get() if session and session.user_id == user.user_id(): session.shared = True session.put() else: return 'Incorrect POST name', 400 date = flask.request.values.get('date', datetime.now().strftime('%Y-%m-%d')) cur_day = datetime.strptime(date, '%Y-%m-%d') next_day = cur_day + timedelta(days=1) sessions = (Session.query(Session.user_id == user.user_id(), Session.start_ts >= cur_day, Session.start_ts < next_day) .order(-Session.start_ts)) num_shared = Session.query(Session.user_id == user.user_id(), Session.shared == True).count() return flask.render_template('main.html', user=user, date=date, year=datetime.now().year, logout_url=users.create_logout_url('/'), sessions=sessions, num_shared=num_shared)
Example #16
Source File: main.py From cas-eval with Apache License 2.0 | 5 votes |
def leaderboard(): user = users.get_current_user() num_shared = [] for u in Session.query(projection=['user_id'], distinct=True): num_shared.append(( Session.query(Session.user_id == u.user_id, Session.shared == True).count(), u.user_id)) num_shared.sort(reverse=True) return flask.render_template('leaderboard.html', user=user, year=datetime.now().year, logout_url=users.create_logout_url('/'), num_shared=num_shared)
Example #17
Source File: main.py From danforth-east with MIT License | 5 votes |
def get(self): user = users.get_current_user() template_values = { 'user': user, 'logout_url': users.create_logout_url('/'), 'config': config, } template = JINJA_ENVIRONMENT.get_template('index.jinja') self.response.write(template.render(template_values))
Example #18
Source File: main.py From danforth-east with MIT License | 5 votes |
def get(self): user = users.get_current_user() if not user: self.redirect('/') return template_values = { 'user': user, 'logout_url': users.create_logout_url('/'), 'config': config, } template = JINJA_ENVIRONMENT.get_template('bad-user.jinja') self.response.write(template.render(template_values))
Example #19
Source File: logout.py From tekton with MIT License | 5 votes |
def index(_resp): facade.logout(_resp).execute() redirect_url = '/' google_user = get_current_user() if google_user: redirect_url = create_logout_url(redirect_url) return RedirectResponse(redirect_url)
Example #20
Source File: blogapp.py From python-for-android with Apache License 2.0 | 5 votes |
def get(self): template_values = { 'sign_out': users.create_logout_url('/'), 'blog_id': self.request.get('id') } # We should have an auth token for this user. token = get_auth_token(self.request) if not token: self.redirect('/blogs') return path = os.path.join(os.path.dirname(__file__), 'post_editor.html') self.response.out.write(template.render(path, template_values))
Example #21
Source File: playground.py From cloud-playground with Apache License 2.0 | 5 votes |
def get(self): # pylint:disable-msg=invalid-name """Handles HTTP GET requests.""" self.redirect(users.create_logout_url('/playground'))
Example #22
Source File: gae_google_account.py From termite-visualizations with BSD 3-Clause "New" or "Revised" License | 5 votes |
def logout_url(self, next="/"): return users.create_logout_url(next)
Example #23
Source File: appengine_main.py From golinks with MIT License | 5 votes |
def get(self, link): user = users.get_current_user() if not user: self.redirect(users.create_login_url(self.request.path)) return sign_out_link = users.create_logout_url('/') is_admin = users.is_current_user_admin() context = { "sign_out_link": sign_out_link, "is_admin": is_admin, "show_visibility": config.ENABLE_GOOGLE_GROUPS_INTEGRATION, 'hostname': config.GOLINKS_HOSTNAME } if link: link = link.rstrip("/") context.update({'key': link}) l = Link.get_by_id(link) if l: if l.owner_id: if l.owner_id != user.user_id() and not is_admin: logging.info( "%s tried to check details page of /%s but doesn't have permission" % (user.email(), link)) errorPage(self.response, 403, "Access denied") return context.update({ 'url': l.url, 'viewcount': l.viewcount, 'public': l.public, 'visibility': l.visibility or '', 'can_delete': 1, 'owner': l.owner_name }) logging.info("%s checked details page of /%s" % (user.email(), link)) self.response.write(render("template/edit.html", context))
Example #24
Source File: show_accounts_view.py From googleads-python-lib with Apache License 2.0 | 5 votes |
def get(self): """Handle get request.""" template_values = { 'back_url': '/showCredentials', 'back_msg': 'View Credentials', 'logout_url': users.create_logout_url('/'), 'user_nickname': users.get_current_user().nickname() } try: try: app_user = InitUser() # Load Client instance. handler = APIHandler(app_user.client_id, app_user.client_secret, app_user.refresh_token, app_user.adwords_manager_cid, app_user.developer_token) # Fetch account info for each client account and place in template. template_values['accounts'] = handler.GetAccounts() except Exception as e: template_values['error'] = str(e) finally: # Use template to write output to the page. path = os.path.join(os.path.dirname(__file__), '../templates/show_accounts.html') self.response.out.write(template.render(path, template_values))
Example #25
Source File: mainold.py From sndlatr with Apache License 2.0 | 5 votes |
def get(self): self.redirect(users.create_logout_url('/'))
Example #26
Source File: main.py From billing-export-python with Apache License 2.0 | 5 votes |
def get(self): """Returns logged in user information.""" user = users.get_current_user() profile_information = {'email': user.email(), 'logoutUrl': users.create_logout_url('/')} self.response.out.write(json.dumps(profile_information))
Example #27
Source File: views.py From isthislegit with BSD 3-Clause "New" or "Revised" License | 5 votes |
def logout(): ''' Manually override the logout URL to avoid completely signing the user out of all Google accounts ''' if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'): return redirect('_ah/logout?continue=https://' + request.host + '/') return redirect(users.create_logout_url('/'))
Example #28
Source File: main.py From datastore-ndb-python with Apache License 2.0 | 5 votes |
def get(self): nickname = 'Anonymous' user = users.get_current_user() if user is not None: nickname = yield get_nickname(user.user_id()) values = {'nickname': nickname, 'login': users.create_login_url('/home'), 'logout': users.create_logout_url('/home'), } self.response.out.write(HOME_PAGE % values) qry, options = self._make_query() pairs = yield qry.map_async(self._hp_callback, options=options) for key, text in pairs: self.response.out.write(text)
Example #29
Source File: recipe-577235.py From code with MIT License | 5 votes |
def get(self, user): logger.info("User was logged in: %r", user) self.response.out.write("%s <a href='%s'>logout</a>" % ( user.email(), users.create_logout_url(self.request.url),))
Example #30
Source File: recipe-577235.py From code with MIT License | 5 votes |
def get(self, user): logger.info("User %r requested %r", user, self.request.url) self.response.out.write("%s <a href='%s'>logout</a>" % ( user.email(), users.create_logout_url(self.request.url),))