Browse Source

improve frontend docker

pull/44/head
Guillaume Vincent 8 years ago
parent
commit
71d38a71fe
4 changed files with 15 additions and 15 deletions
  1. +2
    -3
      Dockerfile
  2. +3
    -5
      app/app.vue
  3. +9
    -6
      app/services/auth.js
  4. +1
    -1
      package.json

+ 2
- 3
Dockerfile View File

@@ -1,4 +1,3 @@
FROM nginx:latest
FROM node:4-onbuild

COPY dist /usr/share/nginx/html/dist/
COPY index.html /usr/share/nginx/html/
EXPOSE 8080

+ 3
- 5
app/app.vue View File

@@ -36,13 +36,11 @@
</a>
<ul class="nav navbar-nav pull-xs-right">
<li class="nav-item">
<a class="btn btn-primary" href="#/entries" v-if="!user.authenticated">
<a class="btn btn-primary" v-link="'entries'" v-if="!user.authenticated">
{{ $t('header.login') }}
</a>
</li>
<li class="nav-item">
<a v-if="user.authenticated" @click="logout()">
Logout
<a class="btn btn-primary-outline" v-link="'login'" v-if="user.authenticated" @click="logout()">
logout
</a>
</li>
</ul>


+ 9
- 6
app/services/auth.js View File

@@ -6,10 +6,11 @@ export default {
},

login(context, credentials, redirect) {
var self = this;
context.$http.post('/api/sessions/', credentials).then(
function (data) {
localStorage.setItem('token', data.token);
this.user.authenticated = true;
function (response) {
localStorage.setItem('token', response.data.token);
self.user.authenticated = true;
if (redirect) {
router.go(redirect)
}
@@ -21,10 +22,12 @@ export default {
},

register(context, user, redirect) {
var self = this;
context.$http.post('/api/users/', user).then(
function (data) {
localStorage.setItem('token', data.token);
this.user.authenticated = true;
function (response) {
localStorage.setItem('token', response.data.token);

self.user.authenticated = true;
if (redirect) {
router.go(redirect)
}


+ 1
- 1
package.json View File

@@ -7,7 +7,7 @@
"test": "mocha --compilers js:babel-core/register tests",
"test:watch": "npm run test -- -w",
"prestart": "npm install",
"start": "webpack-dev-server --inline --hot",
"start": "webpack-dev-server --inline --hot --host 0.0.0.0",
"prebuild": "rimraf dist && npm prune",
"build": "NODE_ENV=production webpack --progress --hide-modules"
},


Loading…
Cancel
Save