fix: remove basic login mode for now (#1554)

* fix: remove basic login mode for now

As described in #1552 I do not have a lot of faith in this feature, so maybe it should just be removed for now until a later release.

* fixup

* fixup

* fixup
This commit is contained in:
Nolan Lawson 2019-10-07 07:15:19 -07:00 committed by GitHub
parent 07d8045617
commit 8f044e19c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 96 deletions

View File

@ -15,8 +15,7 @@ function createKnownError (message) {
} }
function getRedirectUri () { function getRedirectUri () {
const { copyPasteMode } = store.get() return `${location.origin}/settings/instances/add`
return copyPasteMode ? 'urn:ietf:wg:oauth:2.0:oob' : `${location.origin}/settings/instances/add`
} }
async function redirectToOauth () { async function redirectToOauth () {
@ -45,13 +44,8 @@ async function redirectToOauth () {
redirectUri redirectUri
) )
// setTimeout to allow the browser to *actually* save the localStorage data (fixes Safari bug apparently) // setTimeout to allow the browser to *actually* save the localStorage data (fixes Safari bug apparently)
const { copyPasteMode } = store.get()
setTimeout(() => { setTimeout(() => {
if (copyPasteMode) { document.location.href = oauthUrl
window.open(oauthUrl, '_blank', 'noopener')
} else {
document.location.href = oauthUrl
}
}, 200) }, 200)
} }
@ -102,8 +96,7 @@ async function registerNewInstance (code) {
loggedInInstances: loggedInInstances, loggedInInstances: loggedInInstances,
currentInstance: currentRegisteredInstanceName, currentInstance: currentRegisteredInstanceName,
loggedInInstancesInOrder: loggedInInstancesInOrder, loggedInInstancesInOrder: loggedInInstancesInOrder,
instanceThemes: instanceThemes, instanceThemes: instanceThemes
copyPasteMode: false
}) })
store.save() store.save()
const { enableGrayscale } = store.get() const { enableGrayscale } = store.get()
@ -124,16 +117,3 @@ export async function handleOauthCode (code) {
store.set({ logInToInstanceLoading: false }) store.set({ logInToInstanceLoading: false })
} }
} }
export async function handleCopyPasteOauthCode (code) {
const { currentRegisteredInstanceName, currentRegisteredInstance } = store.get()
if (!currentRegisteredInstanceName || !currentRegisteredInstance) {
store.set({
logInToInstanceError: 'You must log in to an instance first.',
logInToInstanceErrorForText: '',
instanceNameInSearch: ''
})
} else {
await handleOauthCode(code)
}
}

View File

@ -33,19 +33,6 @@
Log in Log in
</button> </button>
</form> </form>
{#if $copyPasteMode }
<form aria-label="Enter code" on:submit="onSubmitOauth(event)">
<label for="oauthCodeInput">Code:</label>
<input type="text" id="oauthCodeInput"
bind:value='oauthCode' placeholder="Enter code" required
>
<button class="primary" type="submit" id="submitOauthButton"
disabled={!oauthCode}>
Submit
</button>
</form>
{/if}
</div> </div>
{#if !$isUserLoggedIn} {#if !$isUserLoggedIn}
@ -59,23 +46,6 @@
<ExternalLink href="https://joinmastodon.org">Join Mastodon!</ExternalLink> <ExternalLink href="https://joinmastodon.org">Join Mastodon!</ExternalLink>
</p> </p>
{/if} {/if}
<p>
{#if $copyPasteMode}
Switch back to
{:else}
Trouble logging in? Switch to
{/if}
<button on:click="onCopyPasteModeButtonClick()"
class="copy-paste-mode-button"
aria-pressed={$copyPasteMode}>
{$copyPasteMode ? 'regular' : 'basic'} login mode
</button>.
</p>
{#if $copyPasteMode}
<InfoAside className="add-new-instance-aside">
In basic login mode, click "log in" to open a new window. Then copy the code and paste it above.
</InfoAside>
{/if}
</SettingsLayout> </SettingsLayout>
<style> <style>
.add-new-instance { .add-new-instance {
@ -105,20 +75,6 @@
margin: 20px 5px; margin: 20px 5px;
} }
button.copy-paste-mode-button {
margin: 0;
padding: 0;
display: inline-block;
background: none;
border: none;
font-size: 1em;
color: var(--anchor-text);
}
button.copy-paste-mode-button:hover {
text-decoration: underline;
}
@media (max-width: 767px) { @media (max-width: 767px) {
input { input {
min-width: 95%; min-width: 95%;
@ -129,11 +85,10 @@
<script> <script>
import SettingsLayout from '../../../_components/settings/SettingsLayout.html' import SettingsLayout from '../../../_components/settings/SettingsLayout.html'
import { store } from '../../../_store/store' import { store } from '../../../_store/store'
import { logInToInstance, handleOauthCode, handleCopyPasteOauthCode } from '../../../_actions/addInstance' import { logInToInstance, handleOauthCode } from '../../../_actions/addInstance'
import ExternalLink from '../../../_components/ExternalLink.html' import ExternalLink from '../../../_components/ExternalLink.html'
import { testHasIndexedDB, testHasLocalStorage } from '../../../_utils/testStorage' import { testHasIndexedDB, testHasLocalStorage } from '../../../_utils/testStorage'
import Tooltip from '../../../_components/Tooltip.html' import Tooltip from '../../../_components/Tooltip.html'
import InfoAside from '../../../_components/InfoAside.html'
export default { export default {
async oncreate () { async oncreate () {
@ -149,30 +104,18 @@
components: { components: {
SettingsLayout, SettingsLayout,
ExternalLink, ExternalLink,
Tooltip, Tooltip
InfoAside
}, },
store: () => store, store: () => store,
data: () => ({ data: () => ({
hasIndexedDB: true, hasIndexedDB: true,
hasLocalStorage: true, hasLocalStorage: true
oauthCode: ''
}), }),
methods: { methods: {
onSubmitInstance (event) { onSubmitInstance (event) {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
logInToInstance() logInToInstance()
},
onSubmitOauth (event) {
event.preventDefault()
event.stopPropagation()
handleCopyPasteOauthCode(this.get().oauthCode)
},
onCopyPasteModeButtonClick () {
const { copyPasteMode } = this.store.get()
console.log('copyPasteMode', copyPasteMode)
this.store.set({ copyPasteMode: !copyPasteMode })
} }
} }
} }

View File

@ -1,7 +1,7 @@
import { Selector as $ } from 'testcafe' import { Selector as $ } from 'testcafe'
import { import {
addInstanceButton, addInstanceButton,
authorizeInput, confirmationDialogOKButton, copyPasteModeButton, authorizeInput, confirmationDialogOKButton,
emailInput, emailInput,
formError, formError,
getFirstVisibleStatus, getNthStatus, getOpacity, getFirstVisibleStatus, getNthStatus, getOpacity,
@ -9,10 +9,10 @@ import {
homeNavButton, homeNavButton,
instanceInput, instanceInput,
logInToInstanceLink, logInToInstanceLink,
mastodonLogInButton, oauthCodeInput, mastodonLogInButton,
passwordInput, reload, passwordInput, reload,
settingsButton, settingsButton,
sleep, submitOauthButton sleep
} from '../utils' } from '../utils'
import { loginAsFoobar } from '../roles' import { loginAsFoobar } from '../roles'
@ -96,13 +96,3 @@ test('Logs in, refreshes, then logs out', async t => {
.click(homeNavButton) .click(homeNavButton)
.expect(getOpacity('.hidden-from-ssr')()).eql('1') .expect(getOpacity('.hidden-from-ssr')()).eql('1')
}) })
test('Shows error when entering only oauth code in basic mode', async t => {
await t
.click(logInToInstanceLink)
.click(copyPasteModeButton)
.typeText(oauthCodeInput, 'blahblahblah')
.click(submitOauthButton)
.expect(formError.exists).ok()
.expect(formError.innerText).contains('You must log in to an instance first')
})