|
@@ -0,0 +1,97 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <h3>Google IdToken</h3>
|
|
|
+ <button :disabled="loginDisabled()" @click="loginUsingIdToken">Login</button>
|
|
|
+ <a style="margin: 0em 1em; " href="accessdata.html">GET</a>
|
|
|
+ <div v-if="idToken" style="overflow: hidden; font-size: xx-small; margin: 1em 0em; ">{{ idToken }}</div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts">
|
|
|
+
|
|
|
+import Trottle from 'lodash/throttle'
|
|
|
+import { Component, Prop, Vue, Watch } from 'vue-property-decorator'
|
|
|
+import { getLoginMessageByGoogleIdToken } from '../assets/js/__message-util';
|
|
|
+
|
|
|
+@Component
|
|
|
+export default class GoogleLogin extends Vue {
|
|
|
+ @Prop() public connection;
|
|
|
+ idToken: string = ''
|
|
|
+
|
|
|
+ // @Watch('connection')
|
|
|
+ // updateConn(value, oldValue) {
|
|
|
+ // console.log('updateconn')
|
|
|
+ // this.conn = value
|
|
|
+ // }
|
|
|
+
|
|
|
+ loginDisabled(){
|
|
|
+ if ( this.idToken == null ) return true;
|
|
|
+ return this.idToken == null || this.connection.socketId == null
|
|
|
+ }
|
|
|
+ mounted(){
|
|
|
+ this.idToken = (new URLSearchParams(window.location.search)).get('id_token')
|
|
|
+ }
|
|
|
+
|
|
|
+ // async startSession() {
|
|
|
+ // const ucpId = await this.getResponse( getLoginMessageByGoogleIdToken(this.idToken, 10000), 'signin', (response) => {
|
|
|
+ // console.log('response2', response)
|
|
|
+ // const ucpId = response?.data?.ucpId
|
|
|
+ // if( ucpId == null) throw Error('missing ucpId')
|
|
|
+ // console.log('ucpId', ucpId)
|
|
|
+ // return ucpId
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+
|
|
|
+ // getResponse = Trottle(async (request, operation: string, getReturnData: (response) => any ) => {
|
|
|
+ // this.startLoading()
|
|
|
+ // this.addMessage(operation + ' ...')
|
|
|
+ // let returnData = null
|
|
|
+ // try {
|
|
|
+ // const results = await this.getResponses(request)
|
|
|
+ // // look for error
|
|
|
+ // const responseException = results.find( (r: any) => r?.header?.messageType == 'ResponseException' )
|
|
|
+
|
|
|
+ // if( responseException != null ){
|
|
|
+ // throw Error(responseException?.data)
|
|
|
+ // }
|
|
|
+ // // look for response
|
|
|
+ // const response = results.find( (r: any) => {
|
|
|
+ // const messageType = r?.header?.messageType
|
|
|
+ // return ['FisResponse','Response'].indexOf(messageType) > -1
|
|
|
+ // })
|
|
|
+ // if(response == null){
|
|
|
+ // throw Error('fail to get success response')
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // try extract data
|
|
|
+ // returnData = getReturnData(response)
|
|
|
+
|
|
|
+ // this.addMessage(operation + ' success.')
|
|
|
+ // } catch (error) {
|
|
|
+ // this.addMessage(operation + ' fail :' + error)
|
|
|
+ // }
|
|
|
+ // this.endLoading()
|
|
|
+
|
|
|
+ // console.log('results', returnData)
|
|
|
+ // return returnData;
|
|
|
+ // })
|
|
|
+
|
|
|
+
|
|
|
+ loginUsingIdToken(){
|
|
|
+ this.$emit('loginAction',{
|
|
|
+ request: getLoginMessageByGoogleIdToken(this.idToken, 10000),
|
|
|
+ title: 'signin GoogleIdToken',
|
|
|
+ handle: (response) => {
|
|
|
+ const ucpId = response?.data?.ucpId
|
|
|
+ if( ucpId == null ) throw Error('missing ucpId')
|
|
|
+ return ucpId
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+</style>
|