display welcome message when user is redirected back to step 3
This commit is contained in:
@@ -47,6 +47,11 @@
|
||||
</div>
|
||||
|
||||
<div class="content" v-if="step === 3">
|
||||
<div v-if="isAuthenticated">
|
||||
<h1 class="h2 text-primary">Welcome {{ userName }}!</h1>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<h5>Extra permission</h5>
|
||||
<p>
|
||||
SimpleLogin extension requires the
|
||||
@@ -143,8 +148,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { requestPermission } from "../background/permissions";
|
||||
import {requestPermission} from "../background/permissions";
|
||||
import SLStorage from "../popup/SLStorage";
|
||||
import axios from "axios";
|
||||
import {API_ROUTE} from "../popup/APIService";
|
||||
import EventManager from "../popup/EventManager";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -153,9 +161,16 @@ export default {
|
||||
isChrome:
|
||||
/Chrome/.test(navigator.userAgent) &&
|
||||
/Google Inc/.test(navigator.vendor),
|
||||
isAuthenticated: false,
|
||||
userName: "",
|
||||
};
|
||||
},
|
||||
async mounted() {},
|
||||
async mounted() {
|
||||
// maybe user redirected from the setup_done page
|
||||
if (this.step === 3) {
|
||||
await this.tryGetUserInfo();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async goToCreateNewAccount() {
|
||||
const apiUrl = await SLStorage.get(SLStorage.SETTINGS.API_URL);
|
||||
@@ -180,6 +195,26 @@ export default {
|
||||
);
|
||||
}
|
||||
},
|
||||
async tryGetUserInfo() {
|
||||
const apiUrl = await SLStorage.get(SLStorage.SETTINGS.API_URL);
|
||||
const that = this;
|
||||
|
||||
// check api key
|
||||
axios
|
||||
.get(apiUrl + API_ROUTE.GET_USER_INFO.path, {
|
||||
headers: { Authentication: this.apiKey },
|
||||
})
|
||||
.then(async (res) => {
|
||||
that.userName = res.data.name || res.data.email;
|
||||
that.isAuthenticated = true;
|
||||
|
||||
await SLStorage.set(SLStorage.SETTINGS.API_KEY, this.apiKey);
|
||||
EventManager.broadcast(EventManager.EVENT.SETTINGS_CHANGED);
|
||||
})
|
||||
.catch((err) => {
|
||||
// user isn't authenticated, ignore
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user