Skip to content
Snippets Groups Projects
Commit ac1c19a7 authored by Maxim Filippov's avatar Maxim Filippov :new_moon_with_face:
Browse files

Merge branch 'master' into feature/disable-settings-reports

parents a71c4c29 eeb68baf
No related branches found
No related tags found
1 merge request!43Add ability to disable settings/reports during compile time
......@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- add ability to configure new settings (UploadS3 bucket namespace, Rate limit for Activity pub routes, Email notifications settings, MRF Vocabulary, user bio and name length and others)
- add ability to disable certain features (settings/reports)
- add sign in via PleromaFE
### Changed
......
......@@ -14,7 +14,7 @@ function hasPermission(roles, permissionRoles) {
return roles.some(role => permissionRoles.indexOf(role) >= 0)
}
const whiteList = ['/login', '/auth-redirect']// no redirect whitelist
const whiteList = ['/login', '/auth-redirect', '/login-pleroma']// no redirect whitelist
export const beforeEachRoute = (to, from, next) => {
NProgress.start() // start progress bar
......
......@@ -46,6 +46,11 @@ export const constantRouterMap = [
}
]
},
{
path: '/login-pleroma',
component: () => import('@/views/login/pleroma'),
hidden: true
},
{
path: '/login',
component: () => import('@/views/login/index'),
......
import localforage from 'localforage'
import _ from 'lodash'
const pleromaFEStateKey = 'vuex-lz'
export const authenticateWithPleromaFE = async(store) => {
const pleromaFEState = await localforage.getItem(pleromaFEStateKey)
const token = _.get(pleromaFEState, 'oauth.userToken')
if (token === undefined) {
throw new Error('PleromaFE token not found')
}
await store.dispatch('LoginByPleromaFE', { token })
}
......@@ -9,12 +9,9 @@
</div>
<div class="bullshit">
<div class="bullshit__oops">OOPS!</div>
<div class="bullshit__info">版权所有
<a class="link-type" href="https://wallstreetcn.com" target="_blank">华尔街见闻</a>
</div>
<div class="bullshit__headline">{{ message }}</div>
<div class="bullshit__info">请检查您输入的网址是否正确,请点击以下按钮返回主页或者发送错误报告</div>
<router-link to="/" class="bullshit__return-home">返回首页</router-link>
<div class="bullshit__info">Please make sure you URL is correct</div>
<router-link to="/" class="bullshit__return-home">Go to the home page</router-link>
</div>
</div>
</div>
......@@ -26,7 +23,7 @@ export default {
name: 'Page404',
computed: {
message() {
return '网管说这个页面你不能进......'
return 'There is nothing here'
}
}
}
......@@ -198,7 +195,7 @@ export default {
&__return-home {
display: block;
float: left;
width: 110px;
width: 165px;
height: 36px;
background: #1482f0;
border-radius: 100px;
......
......@@ -53,6 +53,7 @@ import SvgIcon from '@/components/SvgIcon'
import localforage from 'localforage'
import _ from 'lodash'
import i18n from '@/lang'
import { authenticateWithPleromaFE } from '@/services/pleromaAuth'
export default {
name: 'Login',
......@@ -112,16 +113,16 @@ export default {
async handlePleromaFELogin() {
this.loadingPleromaFE = true
try {
await this.$store.dispatch('LoginByPleromaFE', { token: this.pleromaFEState.oauth.userToken })
await authenticateWithPleromaFE(this.$store)
} catch (error) {
this.loadingPleromaFE = false
this.$message.error(i18n.t('login.pleromaFELoginFailed'))
}
this.loadingPleromaFE = false
this.$router.push({ path: this.redirect || '/users/index' })
this.$message.success(i18n.t('login.pleromaFELoginSucceed'))
this.$router.push({ path: this.redirect || '/users/index' })
},
getLoginData() {
const [username, authHost] = this.loginForm.username.split('@')
......
<template>
<div />
</template>
<script>
import { Loading } from 'element-ui'
import { authenticateWithPleromaFE } from '@/services/pleromaAuth'
import i18n from '@/lang'
export default {
name: 'LoginPleroma',
async mounted() {
const loadingInstance = Loading.service({ fullscreen: true })
try {
await authenticateWithPleromaFE(this.$store)
} catch (error) {
this.$message.error(i18n.t('login.pleromaFELoginFailed'))
}
loadingInstance.close()
this.$router.push({ path: '/users/index' })
this.$message.success(i18n.t('login.pleromaFELoginSucceed'))
}
}
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment