Get config and display/hide register button
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<div class="buttons">
|
||||
<router-link class="button is-primary" v-if="!currentUser.id" :to="{ name: 'Register' }">
|
||||
<router-link class="button is-primary" v-if="!currentUser.id && config && config.registrationsOpen" :to="{ name: 'Register' }">
|
||||
<strong>
|
||||
<translate>Sign up</translate>
|
||||
</strong>
|
||||
@@ -51,6 +51,8 @@ import { deleteUserData } from '@/utils/auth';
|
||||
import { LOGGED_PERSON } from '@/graphql/actor';
|
||||
import { IActor, IPerson } from '@/types/actor.model';
|
||||
import { RouteName } from '@/router';
|
||||
import { CONFIG } from '@/graphql/config';
|
||||
import { IConfig } from '@/types/config.model';
|
||||
|
||||
@Component({
|
||||
apollo: {
|
||||
@@ -71,7 +73,10 @@ import { RouteName } from '@/router';
|
||||
loggedPerson: {
|
||||
query: LOGGED_PERSON,
|
||||
},
|
||||
},
|
||||
config: {
|
||||
query: CONFIG,
|
||||
}
|
||||
}
|
||||
})
|
||||
export default class NavBar extends Vue {
|
||||
notifications = [
|
||||
@@ -83,6 +88,7 @@ export default class NavBar extends Vue {
|
||||
searchText: string | null = null;
|
||||
searchSelect = null;
|
||||
loggedPerson!: IPerson;
|
||||
config!: IConfig;
|
||||
|
||||
get items() {
|
||||
return this.search.map(searchEntry => {
|
||||
|
||||
@@ -1,40 +1,10 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const CREATE_USER = gql`
|
||||
mutation CreateUser($email: String!, $password: String!) {
|
||||
createUser(email: $email, password: $password) {
|
||||
email,
|
||||
confirmationSentAt
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const VALIDATE_USER = gql`
|
||||
mutation ValidateUser($token: String!) {
|
||||
validateUser(token: $token) {
|
||||
token,
|
||||
user {
|
||||
id,
|
||||
email,
|
||||
defaultActor {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const CURRENT_USER_CLIENT = gql`
|
||||
export const CONFIG = gql`
|
||||
query {
|
||||
currentUser @client {
|
||||
id,
|
||||
email
|
||||
config {
|
||||
name,
|
||||
registrationsOpen
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPDATE_CURRENT_USER_CLIENT = gql`
|
||||
mutation UpdateCurrentUser($id: Int!, $email: String!) {
|
||||
updateCurrentUser(id: $id, email: $email) @client
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { ICurrentUser } from '@/types/current-user.model';
|
||||
export interface IConfig {
|
||||
name: string,
|
||||
|
||||
export interface ILogin {
|
||||
user: ICurrentUser,
|
||||
|
||||
token: string,
|
||||
registrationsOpen: boolean,
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<translate>Forgot your password ?</translate>
|
||||
</router-link>
|
||||
</div>
|
||||
<div class="control">
|
||||
<div class="control" v-if="config && config.registrationsOpen">
|
||||
<router-link
|
||||
class="button is-text"
|
||||
:to="{ name: 'Register', params: { default_email: credentials.email, default_password: credentials.password }}"
|
||||
@@ -61,12 +61,21 @@ import { ILogin } from '@/types/login.model';
|
||||
import { UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
|
||||
import { onLogin } from '@/vue-apollo';
|
||||
import { RouteName } from '@/router';
|
||||
import { IConfig } from '@/types/config.model';
|
||||
import { CONFIG } from '@/graphql/config';
|
||||
|
||||
@Component
|
||||
@Component({
|
||||
apollo: {
|
||||
config: {
|
||||
query: CONFIG
|
||||
}
|
||||
}
|
||||
})
|
||||
export default class Login extends Vue {
|
||||
@Prop({ type: String, required: false, default: '' }) email!: string;
|
||||
@Prop({ type: String, required: false, default: '' }) password!: string;
|
||||
|
||||
config!: IConfig;
|
||||
credentials = {
|
||||
email: '',
|
||||
password: '',
|
||||
|
||||
Reference in New Issue
Block a user