-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
79 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,91 @@ | ||
<template> | ||
<div> | ||
<header> | ||
Basic Authentication | ||
</header> | ||
<header>Authentication</header> | ||
<section> | ||
<p>A username and password combo for standard HTTP authentication. | ||
<form> | ||
<p v-if="!originalType">What type of authentication should be used?</p> | ||
<ul> | ||
<li> | ||
<label>Username</label> | ||
<input type="text" v-model="credential.username"> | ||
<li v-if="!originalType"> | ||
<label> | ||
<input type="radio" v-model="credential.type" value="none" id="none"> <b>None</b> - The server doesn't require any authentication | ||
</label> | ||
</li> | ||
<li> | ||
<label>Password</label> | ||
<input type="text" v-model="credential.password"> | ||
<li v-if="originalType === 'user' || !originalType"> | ||
<label> | ||
<input type="radio" v-model="credential.type" value="user" id="user"> <b>Username & Password</b> - The server requires a username and password ("Basic" authentication) | ||
</label> | ||
<section v-if="credential.type === 'user'"> | ||
<ul> | ||
<li> | ||
<label>Username</label> | ||
<input type="text" v-model="credential.username"> | ||
</li> | ||
<li> | ||
<label>Password</label> | ||
<input type="text" v-model="credential.password"> | ||
</li> | ||
</ul> | ||
</section> | ||
</li> | ||
<li v-if="originalType === 'token' || !originalType"> | ||
<label> | ||
<input type="radio" v-model="credential.type" value="token" id="token"> <b>Bearer Token</b> - The server uses token-based authentication | ||
</label> | ||
<section v-if="credential.type === 'token'"> | ||
<ul> | ||
<li> | ||
<label>Token</label> | ||
<input type="text" v-model="credential.token"> | ||
</li> | ||
</ul> | ||
</section> | ||
</li> | ||
</ul> | ||
</form> | ||
</section> | ||
<footer> | ||
<button v-on:click="$store.dispatch('cancel')">Cancel</button> | ||
<button v-on:click="next" class="primary">{{ (credential.username && credential.password) ? 'Continue' : 'Skip' }}</button> | ||
</footer> | ||
<Navigation :onNext="next" :disableNext="(credential.type === 'token' && !credential.token) || (credential.type === 'user' && (!credential.username || !credential.password))" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { Navigation } from '@activeprospect/integration-components'; | ||
export default { | ||
data() { | ||
// this isn't a "real" credential, which wouldn't have `type: none` or both password & token | ||
const credentialTemplate = { | ||
username: '', | ||
password: '', | ||
token: '', | ||
package: 'leadconduit-json', | ||
type: 'none' | ||
}; | ||
const existingCredential = this.$store.getters.getCredential; | ||
return { | ||
credential: this.$store.getters.getCredential || { | ||
username: '', | ||
password: '', | ||
package: 'leadconduit-json', | ||
type: 'user' | ||
} | ||
originalType: existingCredential?.type, // used to keep user from changing type when editing | ||
credential: existingCredential || credentialTemplate, | ||
}; | ||
}, | ||
methods: { | ||
next() { | ||
if (this.credential.username && this.credential.password) { | ||
return this.$store.dispatch('createCredential', this.credential); | ||
if (this.credential.type === 'user') { | ||
delete this.credential.token; | ||
this.$store.dispatch('saveCredential', this.credential); | ||
} else if (this.credential.type === 'token') { | ||
delete this.credential.username; | ||
delete this.credential.password; | ||
this.$store.dispatch('saveCredential', this.credential); | ||
} | ||
this.$store.state.ui.create({ 'redirect': 'config'}); | ||
}, | ||
}, | ||
components: { Navigation } | ||
}; | ||
</script> | ||
|
||
<style> | ||
label { | ||
font-weight: normal !important; | ||
} | ||
input[type=text] { | ||
width: 50% | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters