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 () {
const { copyPasteMode } = store.get()
return copyPasteMode ? 'urn:ietf:wg:oauth:2.0:oob' : `${location.origin}/settings/instances/add`
return `${location.origin}/settings/instances/add`
}
async function redirectToOauth () {
@ -45,13 +44,8 @@ async function redirectToOauth () {
redirectUri
)
// setTimeout to allow the browser to *actually* save the localStorage data (fixes Safari bug apparently)
const { copyPasteMode } = store.get()
setTimeout(() => {
if (copyPasteMode) {
window.open(oauthUrl, '_blank', 'noopener')
} else {
document.location.href = oauthUrl
}
}, 200)
}
@ -102,8 +96,7 @@ async function registerNewInstance (code) {
loggedInInstances: loggedInInstances,
currentInstance: currentRegisteredInstanceName,
loggedInInstancesInOrder: loggedInInstancesInOrder,
instanceThemes: instanceThemes,
copyPasteMode: false
instanceThemes: instanceThemes
})
store.save()
const { enableGrayscale } = store.get()
@ -124,16 +117,3 @@ export async function handleOauthCode (code) {
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
</button>
</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>
{#if !$isUserLoggedIn}
@ -59,23 +46,6 @@
<ExternalLink href="https://joinmastodon.org">Join Mastodon!</ExternalLink>
</p>
{/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>
<style>
.add-new-instance {
@ -105,20 +75,6 @@
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) {
input {
min-width: 95%;
@ -129,11 +85,10 @@
<script>
import SettingsLayout from '../../../_components/settings/SettingsLayout.html'
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 { testHasIndexedDB, testHasLocalStorage } from '../../../_utils/testStorage'
import Tooltip from '../../../_components/Tooltip.html'
import InfoAside from '../../../_components/InfoAside.html'
export default {
async oncreate () {
@ -149,30 +104,18 @@
components: {
SettingsLayout,
ExternalLink,
Tooltip,
InfoAside
Tooltip
},
store: () => store,
data: () => ({
hasIndexedDB: true,
hasLocalStorage: true,
oauthCode: ''
hasLocalStorage: true
}),
methods: {
onSubmitInstance (event) {
event.preventDefault()
event.stopPropagation()
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 {
addInstanceButton,
authorizeInput, confirmationDialogOKButton, copyPasteModeButton,
authorizeInput, confirmationDialogOKButton,
emailInput,
formError,
getFirstVisibleStatus, getNthStatus, getOpacity,
@ -9,10 +9,10 @@ import {
homeNavButton,
instanceInput,
logInToInstanceLink,
mastodonLogInButton, oauthCodeInput,
mastodonLogInButton,
passwordInput, reload,
settingsButton,
sleep, submitOauthButton
sleep
} from '../utils'
import { loginAsFoobar } from '../roles'
@ -96,13 +96,3 @@ test('Logs in, refreshes, then logs out', async t => {
.click(homeNavButton)
.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')
})