Move login to oauth.

This commit is contained in:
Roger Braun 2018-10-26 15:16:23 +02:00
parent 7f0e140a4f
commit 9af204b293
12 changed files with 1332 additions and 243 deletions

View file

@ -1,3 +1,4 @@
import oauthApi from "../../services/new_api/oauth.js";
const LoginForm = {
data: () => ({
user: {},
@ -8,6 +9,13 @@ const LoginForm = {
registrationOpen () { return this.$store.state.instance.registrationOpen }
},
methods: {
oAuthLogin () {
oauthApi.login({
oauth: this.$store.state.oauth,
instance: this.$store.state.instance.server,
commit: this.$store.commit
});
},
submit () {
this.$store.dispatch('loginUser', this.user).then(
() => {},

View file

@ -5,23 +5,9 @@
{{$t('login.login')}}
</div>
<div class="panel-body">
<form v-on:submit.prevent='submit(user)' class='login-form'>
<form v-on:submit.prevent='oAuthLogin' class="login-form">
<div class='form-group'>
<label for='username'>{{$t('login.username')}}</label>
<input :disabled="loggingIn" v-model='user.username' class='form-control' id='username' v-bind:placeholder="$t('login.placeholder')">
</div>
<div class='form-group'>
<label for='password'>{{$t('login.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'}" v-if='registrationOpen' class='register'>{{$t('login.register')}}</router-link></div>
<button :disabled="loggingIn" type='submit' class='btn btn-default'>{{$t('login.login')}}</button>
</div>
</div>
<div v-if="authError" class='form-group'>
<div class='alert error'>{{authError}}</div>
<button class="btn btn-default">Login with OAuth</button>
</div>
</form>
</div>

View file

@ -0,0 +1,20 @@
import oauth from '../../services/new_api/oauth.js'
const oac = {
props: ['code'],
mounted () {
if (this.code) {
oauth.getToken({
app: this.$store.state.oauth,
instance: this.$store.state.instance.server,
code: this.code
}).then((result) => {
this.$store.commit("setToken", result.access_token)
this.$store.dispatch("loginUser", result.access_token)
this.$router.push('/main/friends')
})
}
}
}
export default oac

View file

@ -0,0 +1,5 @@
<template>
<h1>...</h1>
</template>
<script src="./oauth_callback.js"></script>