diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index ae36e5e8..ca7c23ec 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -12,6 +12,7 @@ import MuteCard from '../mute_card/mute_card.vue'
import SelectableList from '../selectable_list/selectable_list.vue'
import ProgressButton from '../progress_button/progress_button.vue'
import EmojiInput from '../emoji-input/emoji-input.vue'
+import suggestor from '../emoji-input/suggestor.js'
import Autosuggest from '../autosuggest/autosuggest.vue'
import Importer from '../importer/importer.vue'
import Exporter from '../exporter/exporter.vue'
@@ -81,6 +82,21 @@ const UserSettings = {
user () {
return this.$store.state.users.currentUser
},
+ emojiUserSuggestor () {
+ return suggestor({
+ emoji: [
+ ...this.$store.state.instance.emoji,
+ ...this.$store.state.instance.customEmoji
+ ],
+ users: this.$store.state.users.users
+ })
+ },
+ emojiSuggestor () {
+ suggestor({ emoji: [
+ ...this.$store.state.instance.emoji,
+ ...this.$store.state.instance.customEmoji
+ ]})
+ },
pleromaBackend () {
return this.$store.state.instance.pleromaBackend
},
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 20b10979..d3d333bd 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -22,18 +22,20 @@
{{$t('settings.name_bio')}}
{{$t('settings.name')}}
-
+
+
+
{{$t('settings.bio')}}
-
+
+
+
--
cgit v1.2.3-70-g09d2
From 77eceedbf7a5b53948d7d91b3d228aa303c02081 Mon Sep 17 00:00:00 2001
From: Maksim
Date: Wed, 12 Jun 2019 20:16:55 +0000
Subject: Revert "add TOTP/Recovery Form for mobile version"
This reverts commit a3811f944819430c278b6da6b08dc322a9b9ff65.
---
package.json | 1 +
src/boot/after_store.js | 2 +-
src/boot/routes.js | 4 +-
src/components/auth_form/auth_form.js | 26 +
src/components/login_form/login_form.js | 63 +-
src/components/login_form/login_form.vue | 68 +-
src/components/mfa_form/recovery_form.js | 41 +
src/components/mfa_form/recovery_form.vue | 42 +
src/components/mfa_form/totp_form.js | 40 +
src/components/mfa_form/totp_form.vue | 45 +
src/components/user_panel/user_panel.js | 8 +-
src/components/user_panel/user_panel.vue | 11 +-
src/components/user_settings/confirm.js | 9 +
src/components/user_settings/confirm.vue | 14 +
src/components/user_settings/mfa.js | 152 +++
src/components/user_settings/mfa.vue | 121 +++
src/components/user_settings/mfa_backup_codes.js | 17 +
src/components/user_settings/mfa_backup_codes.vue | 22 +
src/components/user_settings/mfa_totp.js | 49 +
src/components/user_settings/mfa_totp.vue | 23 +
src/components/user_settings/user_settings.js | 4 +-
src/components/user_settings/user_settings.vue | 2 +-
src/i18n/en.json | 39 +-
src/i18n/ru.json | 38 +-
src/main.js | 2 +
src/modules/auth_flow.js | 89 ++
src/modules/instance.js | 1 -
src/services/api/api.service.js | 57 ++
.../backend_interactor_service.js | 11 +
src/services/new_api/mfa.js | 38 +
src/services/new_api/oauth.js | 35 +-
yarn.lock | 1016 +++++++++++++-------
32 files changed, 1654 insertions(+), 436 deletions(-)
create mode 100644 src/components/auth_form/auth_form.js
create mode 100644 src/components/mfa_form/recovery_form.js
create mode 100644 src/components/mfa_form/recovery_form.vue
create mode 100644 src/components/mfa_form/totp_form.js
create mode 100644 src/components/mfa_form/totp_form.vue
create mode 100644 src/components/user_settings/confirm.js
create mode 100644 src/components/user_settings/confirm.vue
create mode 100644 src/components/user_settings/mfa.js
create mode 100644 src/components/user_settings/mfa.vue
create mode 100644 src/components/user_settings/mfa_backup_codes.js
create mode 100644 src/components/user_settings/mfa_backup_codes.vue
create mode 100644 src/components/user_settings/mfa_totp.js
create mode 100644 src/components/user_settings/mfa_totp.vue
create mode 100644 src/modules/auth_flow.js
create mode 100644 src/services/new_api/mfa.js
(limited to 'src/components/user_settings/user_settings.vue')
diff --git a/package.json b/package.json
index 5409645b..0e7572fa 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"lint-fix": "eslint --fix --ext .js,.vue src test/unit/specs test/e2e/specs"
},
"dependencies": {
+ "@chenfengyuan/vue-qrcode": "^1.0.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-lodash": "^3.2.11",
"chromatism": "^3.0.0",
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index 603de348..7510e562 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -92,6 +92,7 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
? 0
: config.logoMargin
})
+ store.commit('authFlow/setInitialStrategy', config.loginMethod)
copyInstanceOption('redirectRootNoLogin')
copyInstanceOption('redirectRootLogin')
@@ -100,7 +101,6 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
copyInstanceOption('formattingOptionsEnabled')
copyInstanceOption('hideMutedPosts')
copyInstanceOption('collapseMessageWithSubject')
- copyInstanceOption('loginMethod')
copyInstanceOption('scopeCopy')
copyInstanceOption('subjectLineBehavior')
copyInstanceOption('postContentType')
diff --git a/src/boot/routes.js b/src/boot/routes.js
index 1a179099..055a0aea 100644
--- a/src/boot/routes.js
+++ b/src/boot/routes.js
@@ -13,7 +13,7 @@ import FollowRequests from 'components/follow_requests/follow_requests.vue'
import OAuthCallback from 'components/oauth_callback/oauth_callback.vue'
import UserSearch from 'components/user_search/user_search.vue'
import Notifications from 'components/notifications/notifications.vue'
-import LoginForm from 'components/login_form/login_form.vue'
+import AuthForm from 'components/auth_form/auth_form.js'
import ChatPanel from 'components/chat_panel/chat_panel.vue'
import WhoToFollow from 'components/who_to_follow/who_to_follow.vue'
import About from 'components/about/about.vue'
@@ -42,7 +42,7 @@ export default (store) => {
{ name: 'friend-requests', path: '/friend-requests', component: FollowRequests },
{ name: 'user-settings', path: '/user-settings', component: UserSettings },
{ name: 'notifications', path: '/:username/notifications', component: Notifications },
- { name: 'login', path: '/login', component: LoginForm },
+ { name: 'login', path: '/login', component: AuthForm },
{ name: 'chat', path: '/chat', component: ChatPanel, props: () => ({ floating: false }) },
{ name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) },
{ name: 'user-search', path: '/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) },
diff --git a/src/components/auth_form/auth_form.js b/src/components/auth_form/auth_form.js
new file mode 100644
index 00000000..e9a6e2d5
--- /dev/null
+++ b/src/components/auth_form/auth_form.js
@@ -0,0 +1,26 @@
+import LoginForm from '../login_form/login_form.vue'
+import MFARecoveryForm from '../mfa_form/recovery_form.vue'
+import MFATOTPForm from '../mfa_form/totp_form.vue'
+import { mapGetters } from 'vuex'
+
+const AuthForm = {
+ name: 'AuthForm',
+ render (createElement) {
+ return createElement('component', { is: this.authForm })
+ },
+ computed: {
+ authForm () {
+ if (this.requiredTOTP) { return 'MFATOTPForm' }
+ if (this.requiredRecovery) { return 'MFARecoveryForm' }
+ return 'LoginForm'
+ },
+ ...mapGetters('authFlow', ['requiredTOTP', 'requiredRecovery'])
+ },
+ components: {
+ MFARecoveryForm,
+ MFATOTPForm,
+ LoginForm
+ }
+}
+
+export default AuthForm
diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js
index dc917e47..1119754e 100644
--- a/src/components/login_form/login_form.js
+++ b/src/components/login_form/login_form.js
@@ -1,28 +1,44 @@
+import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
import oauthApi from '../../services/new_api/oauth.js'
+
const LoginForm = {
data: () => ({
user: {},
- authError: false
+ error: false
}),
computed: {
- loginMethod () { return this.$store.state.instance.loginMethod },
- loggingIn () { return this.$store.state.users.loggingIn },
- registrationOpen () { return this.$store.state.instance.registrationOpen }
+ isPasswordAuth () { return this.requiredPassword },
+ isTokenAuth () { return this.requiredToken },
+ ...mapState({
+ registrationOpen: state => state.instance.registrationOpen,
+ instance: state => state.instance,
+ loggingIn: state => state.users.loggingIn,
+ oauth: state => state.oauth
+ }),
+ ...mapGetters(
+ 'authFlow', ['requiredPassword', 'requiredToken', 'requiredMFA']
+ )
},
methods: {
- oAuthLogin () {
+ ...mapMutations('authFlow', ['requireMFA']),
+ ...mapActions({ login: 'authFlow/login' }),
+ submit () {
+ this.isTokenMethod ? this.submitToken() : this.submitPassword()
+ },
+ submitToken () {
oauthApi.login({
- oauth: this.$store.state.oauth,
- instance: this.$store.state.instance.server,
+ oauth: this.oauth,
+ instance: this.instance.server,
commit: this.$store.commit
})
},
- submit () {
+ submitPassword () {
const data = {
- oauth: this.$store.state.oauth,
- instance: this.$store.state.instance.server
+ oauth: this.oauth,
+ instance: this.instance.server
}
- this.clearError()
+ this.error = false
+
oauthApi.getOrCreateApp(data).then((app) => {
oauthApi.getTokenWithCredentials(
{
@@ -31,24 +47,27 @@ const LoginForm = {
username: this.user.username,
password: this.user.password
}
- ).then(async (result) => {
+ ).then((result) => {
if (result.error) {
- this.authError = result.error
- this.user.password = ''
+ if (result.error === 'mfa_required') {
+ this.requireMFA({app: app, settings: result})
+ } else {
+ this.error = result.error
+ this.focusOnPasswordInput()
+ }
return
}
- this.$store.commit('setToken', result.access_token)
- try {
- await this.$store.dispatch('loginUser', result.access_token)
+ this.login(result).then(() => {
this.$router.push({name: 'friends'})
- } catch (e) {
- console.log(e)
- }
+ })
})
})
},
- clearError () {
- this.authError = false
+ clearError () { this.error = false },
+ focusOnPasswordInput () {
+ let passwordInput = this.$refs.passwordInput
+ passwordInput.focus()
+ passwordInput.setSelectionRange(0, passwordInput.value.length)
}
}
}
diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue
index c6be2e00..a2c5cf8f 100644
--- a/src/components/login_form/login_form.vue
+++ b/src/components/login_form/login_form.vue
@@ -1,47 +1,53 @@
-
-
-
- {{$t('login.login')}}
-
-