Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Unified Diff: appengine/swarming/elements/imp/common/auth-signin.html

Issue 2177353002: Add top level app element (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@hello-oauth
Patch Set: Address feedback and introduce new res/ layer of direction Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/elements/imp/common/auth-signin.html
diff --git a/appengine/swarming/elements/imp/common/auth-signin.html b/appengine/swarming/elements/imp/common/auth-signin.html
deleted file mode 100644
index 635f68bbd45c444d8e4fc6d66f2bff419856adb8..0000000000000000000000000000000000000000
--- a/appengine/swarming/elements/imp/common/auth-signin.html
+++ /dev/null
@@ -1,128 +0,0 @@
-<!--
- Copyright 2016 The LUCI Authors. All rights reserved.
- Use of this source code is governed under the Apache License, Version 2.0
- that can be found in the LICENSE file.
-
- The `auth-signin` element displays sign-in/sign-out button, user email and
- avatar.
- It has a google-signin/google-signin-aware element under the hood that handles
- the actual OAuth logic.
-
- Usage:
-
- <auth-signin></auth-signin>
-
- Properties:
- authHeaders: Object, Use this in iron-ajax to set oauth2 headers.
- authResponse: Object, The raw gapi.auth2.AuthResponse object.
- clientId: String, The client id to authenticate
- profile: Object, Read Only, The email address and imageurl of the logged in user.
- signedIn: Boolean, Read Only, if the user is logged in.
-
- Methods:
- signIn(): Signs the user in by popping up the authorization dialog.
- signOut(): Signs the user out.
-
- Events:
- auth-signin: Fired when the oauth handshake has completed and a user has logged in.
--->
-
-<link rel="import" href="../../bower_components/google-signin/google-signin-aware.html">
-<link rel="import" href="../../bower_components/polymer/polymer.html">
-
-
-<dom-module id="auth-signin">
- <template>
- <style>
- #avatar {
- border-radius: 5px;
- }
- #signinContainer {
- margin-top: 14px;
- }
- </style>
-
- <google-signin-aware id="aware"
- client-id="[[clientId]]"
- scopes="email"
- on-google-signin-aware-success="_onSignin"
- on-google-signin-aware-signed-out="_onSignout">
- </google-signin-aware>
-
- <template is="dom-if" if="[[!signedIn]]">
- <div id="signinContainer">
- <a on-tap="signIn" href="#">Sign in</a>
- </div>
- </template>
-
- <template is="dom-if" if="[[signedIn]]">
- <img id="avatar" src="[[profile.imageUrl]]" width="30" height="30">
- <span>[[profile.email]]</span>
- <span>|</span>
- <a on-tap="signOut" href="#">Sign out</a>
- </template>
- </template>
- <script>
- 'use strict';
- Polymer({
- is: 'auth-signin',
- properties: {
- authHeaders: {
- type: Object,
- computed: "_makeHeader(authResponse)",
- notify: true,
- },
- authResponse: {
- type: Object,
- notify: true,
- },
- clientId: {
- type: String,
- },
- profile: {
- type: Object,
- readOnly: true
- },
- signedIn: {
- type: Boolean,
- readOnly: true,
- value: false
- }
- },
-
- _onSignin: function(e) {
- this._setSignedIn(true);
- var user = gapi.auth2.getAuthInstance().currentUser.get();
- var profile = user.getBasicProfile();
- this._setProfile({
- email: profile.getEmail(),
- imageUrl: profile.getImageUrl()
- });
- this.set("authResponse", user.getAuthResponse());
- this.fire("auth-signin");
- },
-
- _onSignout: function(e) {
- this._setSignedIn(false);
- this._setProfile(null);
- },
-
- _makeHeader: function(authResponse) {
- if (!authResponse) {
- return {};
- }
- return {
- "authorization": authResponse.token_type + " " + authResponse.access_token
- };
- },
-
- signIn: function() {
- this.$.aware.signIn();
- },
-
- signOut: function() {
- this.$.aware.signOut();
- }
- });
- </script>
-</dom-module>
« no previous file with comments | « appengine/swarming/elements/elements.html ('k') | appengine/swarming/elements/imp/index/swarming-index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698