aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/login_form/login_form.vue5
-rw-r--r--src/components/registration/registration.js21
2 files changed, 22 insertions, 4 deletions
diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue
index aaaca777..db389716 100644
--- a/src/components/login_form/login_form.vue
+++ b/src/components/login_form/login_form.vue
@@ -7,7 +7,10 @@
<div class="panel-body">
<form v-on:submit.prevent='oAuthLogin' class="login-form">
<div class='form-group'>
- <button class="btn btn-default">Login with OAuth</button>
+ <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>
</form>
</div>
diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js
index 8f59878d..cdcc33c9 100644
--- a/src/components/registration/registration.js
+++ b/src/components/registration/registration.js
@@ -1,3 +1,5 @@
+import oauthApi from '../../services/new_api/oauth.js'
+
const registration = {
data: () => ({
user: {},
@@ -25,9 +27,22 @@ const registration = {
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
+ const data = {
+ oauth: this.$store.state.oauth,
+ instance: this.$store.state.instance.server
+ }
+ oauthApi.getOrCreateApp(data).then((app) => {
+ oauthApi.getTokenWithCredentials(
+ {app,
+ instance: data.instance,
+ username: this.user.username,
+ password: this.user.password})
+ .then((result) => {
+ this.$store.commit('setToken', result.access_token)
+ this.$store.dispatch('loginUser', result.access_token)
+ this.$router.push('/main/friends')
+ })
+ })
} else {
this.registering = false
response.json().then((data) => {