mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Feature: Cange Username
This commit is contained in:
parent
3be482c40e
commit
e804aa655c
@ -120,12 +120,14 @@ const loginAPI = {
|
|||||||
}
|
}
|
||||||
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
|
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
|
||||||
},
|
},
|
||||||
changeUsernameProfile: async (sessionId, email, usernameNew) => {
|
changeUsernameProfile: async (sessionId, email, username) => {
|
||||||
|
console.log('changeUsernameProfile', username)
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
session_id: sessionId,
|
session_id: sessionId,
|
||||||
email,
|
email,
|
||||||
update: {
|
update: {
|
||||||
'User.usernameNew': usernameNew,
|
'User.username': username,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
|
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
|
||||||
|
|||||||
@ -3,11 +3,11 @@
|
|||||||
<b-container>
|
<b-container>
|
||||||
<b-row class="mb-4 text-right">
|
<b-row class="mb-4 text-right">
|
||||||
<b-col class="text-right">
|
<b-col class="text-right">
|
||||||
<a href="#formusername" v-if="edit_username" @click="edit_username = !edit_username">
|
<a href="#formusername" v-if="editUsername" @click="editUsername = !editUsername">
|
||||||
<span>{{ $t('form.username') }} {{ $t('form.change') }}</span>
|
<span>{{ $t('form.username') }} {{ $t('form.change') }}</span>
|
||||||
</a>
|
</a>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<a href="#formusername" @click="edit_username = !edit_username">
|
<a href="#formusername" @click="editUsername = !editUsername">
|
||||||
<span>
|
<span>
|
||||||
<b>{{ $t('form.cancel') }}</b>
|
<b>{{ $t('form.cancel') }}</b>
|
||||||
</span>
|
</span>
|
||||||
@ -20,16 +20,16 @@
|
|||||||
<b-col class="col-lg-3 col-md-10 col-sm-10 text-md-left text-lg-right">
|
<b-col class="col-lg-3 col-md-10 col-sm-10 text-md-left text-lg-right">
|
||||||
<small>{{ $t('form.username') }}</small>
|
<small>{{ $t('form.username') }}</small>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col v-if="edit_username" class="col-md-9 col-sm-10">@{{ $store.state.username }}</b-col>
|
<b-col v-if="editUsername" class="col-md-9 col-sm-10">@{{ username }}</b-col>
|
||||||
<b-col v-else class="col-md-9 col-sm-10">
|
<b-col v-else class="col-md-9 col-sm-10">
|
||||||
<validation-observer v-slot="{ handleSubmit }" ref="formValidator">
|
<validation-observer ref="formValidator">
|
||||||
<b-form role="form" @submit.prevent="handleSubmit(onSubmit)">
|
<b-form role="form">
|
||||||
<b-form-input v-model="username" :placeholder="$store.state.username"></b-form-input>
|
<b-form-input v-model="form.username" :placeholder="username"></b-form-input>
|
||||||
<div>
|
<div>
|
||||||
{{ $t('form.change_username_info') }}
|
{{ $t('form.change_username_info') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center" ref="submitButton">
|
<div class="text-center" ref="submitButton">
|
||||||
<b-button type="submit" class="mt-4">
|
<b-button type="button" @click="onSubmit" class="mt-4">
|
||||||
{{ $t('form.save') }}
|
{{ $t('form.save') }}
|
||||||
</b-button>
|
</b-button>
|
||||||
</div>
|
</div>
|
||||||
@ -47,16 +47,29 @@ export default {
|
|||||||
name: 'FormUsername',
|
name: 'FormUsername',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
edit_username: true,
|
editUsername: true,
|
||||||
username: '',
|
username: this.$store.state.username,
|
||||||
|
form: {
|
||||||
|
username: this.$store.state.username,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
props: {
|
||||||
|
UserProfileTestData: { type: Object },
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
// console.log(this.data)
|
console.log('onSubmit', this.form.username)
|
||||||
const result = await loginAPI.changeUsernameProfile(this.username)
|
const result = await loginAPI.changeUsernameProfile(
|
||||||
|
this.$store.state.sessionId,
|
||||||
|
this.$store.state.email,
|
||||||
|
{
|
||||||
|
username: this.form.username,
|
||||||
|
},
|
||||||
|
)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert('changeUsername success')
|
this.$store.commit('username', this.form.username)
|
||||||
|
this.editUserdata = true
|
||||||
} else {
|
} else {
|
||||||
alert(result.result.message)
|
alert(result.result.message)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user