Final gist integration + clean up

This commit is contained in:
Liyas Thomas
2020-12-08 17:50:32 +05:30
parent b1587950c6
commit ba08883623
6 changed files with 59 additions and 29 deletions

View File

@@ -18,16 +18,21 @@
</button>
</div>
<div
v-tooltip="{
content:
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
? $t('login_with_github_to') + $t('create_secret_gist')
: null,
v-tooltip.bottom="{
content: !fb.currentUser
? $t('login_with_github_to') + $t('create_secret_gist')
: fb.currentUser.provider !== 'github.com'
? $t('login_with_github_to') + $t('create_secret_gist')
: null,
}"
>
<button
:disabled="
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
!fb.currentUser
? true
: fb.currentUser.provider !== 'github.com'
? true
: false
"
class="icon"
@click="createCollectionGist"
@@ -139,7 +144,7 @@ export default {
},
{
headers: {
Authorization: `token ${this.$store.state.postwoman.providerInfo.accessToken}`,
Authorization: `token ${fb.currentUser.accessToken}`,
Accept: "application/vnd.github.v3+json",
},
}

View File

@@ -18,16 +18,21 @@
</button>
</div>
<div
v-tooltip="{
content:
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
? $t('login_with_github_to') + $t('create_secret_gist')
: null,
v-tooltip.bottom="{
content: !fb.currentUser
? $t('login_with_github_to') + $t('create_secret_gist')
: fb.currentUser.provider !== 'github.com'
? $t('login_with_github_to') + $t('create_secret_gist')
: null,
}"
>
<button
:disabled="
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
!fb.currentUser
? true
: fb.currentUser.provider !== 'github.com'
? true
: false
"
class="icon"
@click="createEnvironmentGist"
@@ -139,7 +144,7 @@ export default {
},
{
headers: {
Authorization: `token ${this.$store.state.postwoman.providerInfo.accessToken}`,
Authorization: `token ${fb.currentUser.accessToken}`,
Accept: "application/vnd.github.v3+json",
},
}

View File

@@ -62,6 +62,7 @@ export default {
this.showLoginSuccess()
} catch (err) {
console.log(err)
// An error happened.
if (err.code === "auth/account-exists-with-different-credential") {
// Step 2.
@@ -80,22 +81,23 @@ export default {
// Asks the user their password.
// In real scenario, you should handle this asynchronously.
const password = promptUserForPassword() // TODO: implement promptUserForPassword.
const user = await fb.signInWithEmailAndPassword(email, password)
const user = await fb.signInWithEmailAndPassword(email, password)
await user.linkWithCredential(pendingCred)
this.showLoginSuccess()
return
}
this.$toast.info(`${this.$t("login_with")}`, {
this.$toast.info(`${this.$t("account_exists")}`, {
icon: "vpn_key",
duration: null,
closeOnSwipe: false,
action: {
text: this.$t("yes"),
onClick: async (e, toastObject) => {
const user = await fb.signInWithGithub()
const { user } = await fb.signInWithGithub()
await user.linkAndRetrieveDataWithCredential(pendingCred)
this.showLoginSuccess()
@@ -111,10 +113,7 @@ export default {
try {
const { credential, additionalUserInfo } = await fb.signInUserWithGithub()
this.$store.commit("postwoman/setProviderInfo", {
providerId: "github.com",
accessToken: credential.accessToken,
})
fb.setProviderInfo(credential.providerId, credential.accessToken)
if (additionalUserInfo.isNewUser) {
this.$toast.info(`${this.$t("turn_on")} ${this.$t("sync")}`, {
@@ -136,6 +135,7 @@ export default {
this.showLoginSuccess()
} catch (err) {
console.log(err)
// An error happened.
if (err.code === "auth/account-exists-with-different-credential") {
// Step 2.
@@ -163,7 +163,7 @@ export default {
return
}
this.$toast.info(`${this.$t("login_with")}`, {
this.$toast.info(`${this.$t("account_exists")}`, {
icon: "vpn_key",
duration: null,
closeOnSwipe: false,