Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
8 KB
Referenced Files
None
Subscribers
None
diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js
index 1a6f601543..a117b76fd2 100644
--- a/src/components/login_form/login_form.js
+++ b/src/components/login_form/login_form.js
@@ -1,23 +1,24 @@
const LoginForm = {
data: () => ({
user: {},
authError: false
}),
computed: {
- loggingIn () { return this.$store.state.users.loggingIn }
+ loggingIn () { return this.$store.state.users.loggingIn },
+ registrationOpen () { return this.$store.state.config.registrationOpen }
},
methods: {
submit () {
this.$store.dispatch('loginUser', this.user).then(
() => {},
(error) => {
this.authError = error
this.user.username = ''
this.user.password = ''
}
)
}
}
}
export default LoginForm
diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue
index 585af6f64e..d629114820 100644
--- a/src/components/login_form/login_form.vue
+++ b/src/components/login_form/login_form.vue
@@ -1,70 +1,70 @@
<template>
<div class="login panel panel-default base00-background">
<!-- Default panel contents -->
<div class="panel-heading base01-background base04">
Log in
</div>
<div class="panel-body">
<form v-on:submit.prevent='submit(user)' class='login-form'>
<div class='form-group'>
<label for='username'>Username</label>
<input :disabled="loggingIn" v-model='user.username' class='form-control' id='username' placeholder='e.g. lain'>
</div>
<div class='form-group'>
<label for='password'>Password</label>
<input :disabled="loggingIn" v-model='user.password' class='form-control' id='password' type='password'>
</div>
<div class='form-group'>
<div class='login-bottom'>
- <div><router-link :to="{name: 'registration'}" class='register'>Register</router-link></div>
+ <div><router-link :to="{name: 'registration'}" v-if='registrationOpen' class='register'>Register</router-link></div>
<button :disabled="loggingIn" type='submit' class='btn btn-default base05 base01-background'>Log in</button>
</div>
</div>
<div v-if="authError" class='form-group'>
<div class='error base05'>{{authError}}</div>
</div>
</form>
</div>
</div>
</template>
<script src="./login_form.js" ></script>
<style lang="scss">
.login-form {
input {
border-width: 1px;
border-style: solid;
border-color: silver;
border-radius: 5px;
padding: 0.1em 0.2em 0.2em 0.2em;
}
.btn {
min-height: 28px;
width: 10em;
}
.error {
border-radius: 5px;
text-align: center;
background-color: rgba(255, 48, 16, 0.65);
min-height: 28px;
line-height: 28px;
}
.register {
flex: 1 1;
}
.login-bottom {
margin-top: 1.0em;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
}
</style>
diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js
index 9e99197c29..771b3b2750 100644
--- a/src/components/registration/registration.js
+++ b/src/components/registration/registration.js
@@ -1,32 +1,37 @@
const registration = {
data: () => ({
user: {},
error: false,
registering: false
}),
+ created () {
+ if (!this.$store.state.config.registrationOpen || !!this.$store.state.users.currentUser) {
+ this.$router.push('/main/all')
+ }
+ },
computed: {
termsofservice () { return this.$store.state.config.tos }
},
methods: {
submit () {
this.registering = true
this.user.nickname = this.user.username
this.$store.state.api.backendInteractor.register(this.user).then(
(response) => {
if (response.ok) {
this.$store.dispatch('loginUser', this.user)
this.$router.push('/main/all')
this.registering = false
} else {
this.registering = false
response.json().then((data) => {
this.error = data.error
})
}
}
)
}
}
}
export default registration
diff --git a/src/main.js b/src/main.js
index 52b820c28b..4b7891ed06 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,100 +1,101 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Vuex from 'vuex'
import App from './App.vue'
import PublicTimeline from './components/public_timeline/public_timeline.vue'
import PublicAndExternalTimeline from './components/public_and_external_timeline/public_and_external_timeline.vue'
import FriendsTimeline from './components/friends_timeline/friends_timeline.vue'
import ConversationPage from './components/conversation-page/conversation-page.vue'
import Mentions from './components/mentions/mentions.vue'
import UserProfile from './components/user_profile/user_profile.vue'
import Settings from './components/settings/settings.vue'
import Registration from './components/registration/registration.vue'
import statusesModule from './modules/statuses.js'
import usersModule from './modules/users.js'
import apiModule from './modules/api.js'
import configModule from './modules/config.js'
import VueTimeago from 'vue-timeago'
import createPersistedState from './lib/persisted_state.js'
Vue.use(Vuex)
Vue.use(VueRouter)
Vue.use(VueTimeago, {
locale: 'en-US',
locales: {
'en-US': require('../static/timeago.json')
}
})
const persistedStateOptions = {
paths: [
'config.hideAttachments',
'config.hideAttachmentsInConv',
'config.hideNsfw',
'config.autoLoad',
'config.hoverPreview',
'config.muteWords',
'statuses.notifications',
'users.users'
]
}
const store = new Vuex.Store({
modules: {
statuses: statusesModule,
users: usersModule,
api: apiModule,
config: configModule
},
plugins: [createPersistedState(persistedStateOptions)],
strict: process.env.NODE_ENV !== 'production'
})
const routes = [
{ name: 'root', path: '/', redirect: '/main/all' },
{ path: '/main/all', component: PublicAndExternalTimeline },
{ path: '/main/public', component: PublicTimeline },
{ path: '/main/friends', component: FriendsTimeline },
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
{ name: 'user-profile', path: '/users/:id', component: UserProfile },
{ name: 'mentions', path: '/:username/mentions', component: Mentions },
{ name: 'settings', path: '/settings', component: Settings },
{ name: 'registration', path: '/registration', component: Registration }
]
const router = new VueRouter({
mode: 'history',
routes,
scrollBehavior: (to, from, savedPosition) => {
if (to.matched.some(m => m.meta.dontScroll)) {
return false
}
return savedPosition || { x: 0, y: 0 }
}
})
/* eslint-disable no-new */
new Vue({
router,
store,
el: '#app',
render: h => h(App)
})
window.fetch('/static/config.json')
.then((res) => res.json())
- .then(({name, theme, background, logo, tos}) => {
+ .then(({name, theme, background, logo, registrationOpen}) => {
store.dispatch('setOption', { name: 'name', value: name })
store.dispatch('setOption', { name: 'theme', value: theme })
store.dispatch('setOption', { name: 'background', value: background })
store.dispatch('setOption', { name: 'logo', value: logo })
+ store.dispatch('setOption', { name: 'registrationOpen', value: registrationOpen })
})
window.fetch('/static/terms-of-service.html')
.then((res) => res.text())
.then((html) => {
store.dispatch('setOption', { name: 'tos', value: html })
})
diff --git a/static/config.json b/static/config.json
index 3b6d56c44a..195ee04690 100644
--- a/static/config.json
+++ b/static/config.json
@@ -1,6 +1,7 @@
{
"name": "Pleroma FE",
"theme": "base16-pleroma-dark.css",
"background": "/static/bg.jpg",
- "logo": "/static/logo.png"
+ "logo": "/static/logo.png",
+ "registrationOpen": false
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Nov 19, 4:39 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1840942
Default Alt Text
(8 KB)

Event Timeline