Update Password + Signup
This commit is contained in:
@@ -4260,14 +4260,6 @@ export const tools = {
|
||||
}
|
||||
console.log('errorMsg', cosa, item)
|
||||
|
||||
if (cosa === 'repeatpassword') {
|
||||
if (item.sameAsPassword) {
|
||||
if (item.sameAsPassword.$invalid) {
|
||||
return t('reg.err.sameaspassword')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item.email) {
|
||||
if (item.email.$invalid)
|
||||
return t('reg.err.email')
|
||||
@@ -4310,6 +4302,12 @@ export const tools = {
|
||||
}
|
||||
} else if ((cosa === 'name') || (cosa === 'surname')) {
|
||||
// console.log(item);
|
||||
} else if (cosa === 'repeatpassword') {
|
||||
if (item.matchText) {
|
||||
if (item.matchText.$invalid) {
|
||||
return t('reg.err.sameaspassword')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ''
|
||||
|
||||
@@ -141,10 +141,13 @@ export const toolsext = {
|
||||
const globalStore = useGlobalStore()
|
||||
if (table === 'users') {
|
||||
if (keystr === 'profile') {
|
||||
if (subkey) { // @ts-ignore
|
||||
if (subkey) {
|
||||
console.log('userStore.my.profile', userStore.my.profile, 'subkey', subkey, )
|
||||
// @ts-ignore
|
||||
return userStore.my.profile[subkey]
|
||||
}
|
||||
} else if (keystr) { // @ts-ignore
|
||||
// @ts-ignore
|
||||
return userStore.my[keystr]
|
||||
}
|
||||
} else if (table === 'todos') {
|
||||
|
||||
@@ -108,28 +108,6 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
getters: {
|
||||
|
||||
getUserByUsername: (state: IUserState) => (username: string): IUserFields | null => {
|
||||
// Check if is this User!
|
||||
if (state.my.username === username) return state.my
|
||||
|
||||
let trovato = null
|
||||
if (state.usersList) trovato = state.usersList.find((item) => item.username === username)
|
||||
|
||||
return (trovato) || null
|
||||
},
|
||||
|
||||
getImgByUsername: (state: IUserState) => (username: string): string => {
|
||||
if (username === '') return ''
|
||||
// Check if is this User!
|
||||
// @ts-ignore
|
||||
const myrec = this.getUserByUsername(username)
|
||||
// console.log('myrec', myrec)
|
||||
if (myrec && myrec.profile && !!myrec.profile.img && myrec.profile.img !== '' && myrec.profile.img !== 'undefined') {
|
||||
return myrec.profile.img
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
isServerError(): boolean {
|
||||
return (this.servercode === toolsext.ERR_SERVERFETCH)
|
||||
},
|
||||
@@ -137,21 +115,6 @@ export const useUserStore = defineStore('UserStore', {
|
||||
getServerCode: (state: IUserState): number => (state.servercode ? state.servercode : 0),
|
||||
getMsg: (state: IUserState): string => (state.msg ? state.msg : ''),
|
||||
|
||||
getNameSurnameByUserId: (state: IUserState) => (userId: string): string => {
|
||||
|
||||
// @ts-ignore
|
||||
const user = this.getUserByUserId(state, userId)
|
||||
if (user) return `${user.name} ${user.surname}`
|
||||
return `(${userId})`
|
||||
},
|
||||
|
||||
getNameSurnameByUsername: (state: IUserState) => (username: string): string => {
|
||||
// @ts-ignore
|
||||
const user = this.getUserByUsername(state, username)
|
||||
if (user) return `${user.name} ${user.surname}`
|
||||
return `(${username})`
|
||||
},
|
||||
|
||||
getUsersList: (mystate: IUserState) => {
|
||||
return mystate.usersList
|
||||
},
|
||||
@@ -169,17 +132,6 @@ export const useUserStore = defineStore('UserStore', {
|
||||
},
|
||||
|
||||
|
||||
getUserByUserId: (state: IUserState) => (userId: string): IUserFields | null => {
|
||||
// Check if is this User!
|
||||
if (state.my._id === userId) return state.my
|
||||
|
||||
let trovato = null
|
||||
|
||||
if (state.usersList) trovato = state.usersList.find((item) => item._id === userId)
|
||||
|
||||
return (trovato) || null
|
||||
},
|
||||
|
||||
isTokenInvalid: (state: IUserState) => {
|
||||
try {
|
||||
return (state.my.tokens!.length <= 0)
|
||||
@@ -196,11 +148,60 @@ export const useUserStore = defineStore('UserStore', {
|
||||
}
|
||||
},
|
||||
|
||||
getMsgError: (state: IUserState) => (err: number): string => {
|
||||
},
|
||||
|
||||
actions: {
|
||||
getUserByUsername(username: string): IUserFields | null {
|
||||
// Check if is this User!
|
||||
if (this.my.username === username) return this.my
|
||||
|
||||
let trovato = null
|
||||
if (this.usersList) trovato = this.usersList.find((item: any) => item.username === username)
|
||||
|
||||
return (trovato) || null
|
||||
},
|
||||
|
||||
|
||||
getImgByUsername(username: string): string {
|
||||
if (username === '') return ''
|
||||
// Check if is this User!
|
||||
const myrec = this.getUserByUsername(username)
|
||||
// console.log('myrec', myrec)
|
||||
if (myrec && myrec.profile && !!myrec.profile.img && myrec.profile.img !== '' && myrec.profile.img !== 'undefined') {
|
||||
return myrec.profile.img
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
getNameSurnameByUserId(userId: string): string {
|
||||
|
||||
const user = this.getUserByUserId(userId)
|
||||
if (user) return `${user.name} ${user.surname}`
|
||||
return `(${userId})`
|
||||
},
|
||||
|
||||
getNameSurnameByUsername(username: string): string {
|
||||
const user = this.getUserByUsername(username)
|
||||
if (user) return `${user.name} ${user.surname}`
|
||||
return `(${username})`
|
||||
},
|
||||
|
||||
getUserByUserId(userId: string): IUserFields | null {
|
||||
// Check if is this User!
|
||||
if (this.my._id === userId) return this.my
|
||||
|
||||
let trovato = null
|
||||
|
||||
if (this.usersList) trovato = this.usersList.find((item: any) => item._id === userId)
|
||||
|
||||
return (trovato) || null
|
||||
},
|
||||
|
||||
getMsgError(err: number): string {
|
||||
let msgerrore = ''
|
||||
if (err !== tools.OK) {
|
||||
msgerrore = `Error [${state.servercode}]: `
|
||||
if (state.servercode === toolsext.ERR_SERVERFETCH) {
|
||||
msgerrore = `Error [${this.servercode}]: `
|
||||
if (this.servercode === toolsext.ERR_SERVERFETCH) {
|
||||
msgerrore = translate('fetch.errore_server')
|
||||
} else {
|
||||
msgerrore = translate('fetch.errore_generico')
|
||||
@@ -215,9 +216,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return msgerrore
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
actions: {
|
||||
clearAuthData() {
|
||||
this.my = DefaultUser
|
||||
// resetArrToken(mystate.my.tokens)
|
||||
@@ -232,18 +231,6 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return true
|
||||
},
|
||||
|
||||
setErrorCatch(axerr: Types.AxiosError) {
|
||||
try {
|
||||
if (this.servercode !== toolsext.ERR_SERVERFETCH) {
|
||||
this.servercode = axerr.getCode()
|
||||
}
|
||||
// this.msg = axerr.getMsg()
|
||||
console.log('Err catch: (servercode:', axerr.getCode(), axerr.getMsgError(), ')')
|
||||
} catch (e) {
|
||||
console.log('Err catch:', axerr)
|
||||
}
|
||||
},
|
||||
|
||||
async resetpwd(paramquery: any) {
|
||||
|
||||
const mydata = { ...paramquery }
|
||||
@@ -265,6 +252,18 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
},
|
||||
|
||||
setErrorCatch(axerr: Types.AxiosError) {
|
||||
try {
|
||||
if (this.servercode !== toolsext.ERR_SERVERFETCH) {
|
||||
this.servercode = axerr.getCode()
|
||||
}
|
||||
// this.msg = axerr.getMsg()
|
||||
console.log('Err catch: (servercode:', axerr.getCode(), axerr.getMsgError(), ')')
|
||||
} catch (e) {
|
||||
console.log('Err catch:', axerr)
|
||||
}
|
||||
},
|
||||
|
||||
async setLangServer() {
|
||||
const mydata = {
|
||||
username: this.my.username,
|
||||
|
||||
Reference in New Issue
Block a user