mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
merge into master
This commit is contained in:
commit
3c65eebc61
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -212,7 +212,7 @@ jobs:
|
||||
report_name: Coverage Frontend
|
||||
type: lcov
|
||||
result_path: ./coverage/lcov.info
|
||||
min_coverage: 11
|
||||
min_coverage: 12
|
||||
token: ${{ github.token }}
|
||||
|
||||
#test:
|
||||
|
||||
@ -37,9 +37,9 @@ services:
|
||||
#########################################################
|
||||
## COMMUNITY SERVER (cakephp with php-fpm) ##############
|
||||
#########################################################
|
||||
community-server:
|
||||
volumes:
|
||||
- ./community_server
|
||||
#community-server:
|
||||
# volumes:
|
||||
# - ./community_server
|
||||
|
||||
|
||||
#########################################################
|
||||
|
||||
@ -65,7 +65,6 @@
|
||||
"vue-cli-plugin-i18n": "^1.0.1",
|
||||
"vue-clickaway": "^2.2.2",
|
||||
"vue-clipboard2": "^0.3.0",
|
||||
"vue-cookies": "^1.7.4",
|
||||
"vue-flatpickr-component": "^8.1.2",
|
||||
"vue-good-table": "^2.21.3",
|
||||
"vue-i18n": "^8.22.4",
|
||||
@ -75,7 +74,8 @@
|
||||
"vue-qrcode-reader": "^2.3.16",
|
||||
"vue-router": "^3.0.6",
|
||||
"vue2-transitions": "^0.2.3",
|
||||
"vuex": "^3.6.0"
|
||||
"vuex": "^3.6.0",
|
||||
"vuex-persistedstate": "^4.0.0-beta.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.7.0",
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
</header>
|
||||
<div class="">
|
||||
<particles-bg type="custom" :config="config" :bg="true" />
|
||||
<component :is="$store.state.session_id ? 'DashboardLayout' : 'AuthLayoutGDD'" />
|
||||
<component :is="$route.meta.requiresAuth ? 'DashboardLayout' : 'AuthLayoutGDD'" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -38,31 +38,9 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
session_id: null,
|
||||
email: '',
|
||||
language: 'en',
|
||||
}
|
||||
},
|
||||
created() {
|
||||
//console.log('xx', $cookies.get('gdd_lang'))
|
||||
//console.log('%cWillkommen bei Gradido %cgreen text', 'font-weight:bold', 'color: green')
|
||||
if ($cookies.isKey('gdd_session_id') == true) {
|
||||
//console.log('%cHey %c' + $cookies.get('gdd_u') + '', 'font-weight:bold', 'color: orange')
|
||||
this.$store.commit('session_id', $cookies.get('gdd_session_id'))
|
||||
this.$store.commit('email', $cookies.get('gdd_u'))
|
||||
if ($cookies.get('gdd_lang') != 'de' || $cookies.get('gdd_lang') != 'de') {
|
||||
this.$store.commit('language', 'de')
|
||||
} else {
|
||||
this.$store.commit('language', $cookies.get('gdd_lang'))
|
||||
}
|
||||
|
||||
this.$i18n.locale = $cookies.get('gdd_lang')
|
||||
this.$router.push('overview')
|
||||
} else {
|
||||
//console.log('app.vue to Logout')
|
||||
this.$store.dispatch('logout')
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
config: {
|
||||
|
||||
@ -63,6 +63,15 @@ const loginAPI = {
|
||||
}
|
||||
return apiPost(CONFIG.LOGIN_API_URL + 'createUser', payload)
|
||||
},
|
||||
sendEmail: async (email, email_text = 7, email_verification_code_type = 'resetPassword') => {
|
||||
//console.log('api email', email)
|
||||
const payload = {
|
||||
email,
|
||||
email_text,
|
||||
email_verification_code_type,
|
||||
}
|
||||
return apiPost(CONFIG.LOGIN_API_URL + 'sendEmail', payload)
|
||||
},
|
||||
}
|
||||
|
||||
export default loginAPI
|
||||
|
||||
@ -69,7 +69,6 @@ export default {
|
||||
methods: {
|
||||
dismissAlert() {
|
||||
this.visible = false
|
||||
this.$store.state.loginfail = false
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
</b-row>
|
||||
<slot name="mobile-right">
|
||||
<ul class="nav align-items-center d-md-none">
|
||||
<a slot="title-container" class="nav-link" href="#" role="button">
|
||||
<a slot="title-container" class="nav-link" role="button">
|
||||
<div class="media align-items-center">
|
||||
<span class="avatar avatar-sm">
|
||||
<vue-qrcode :value="$store.state.email" type="image/png"></vue-qrcode>
|
||||
@ -58,7 +58,7 @@
|
||||
<hr class="my-3" />
|
||||
<ul class="navbar-nav mb-md-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-lg" href="#!" @click="logout">
|
||||
<a class="nav-link text-lg" @click="logout">
|
||||
{{ $t('logout') }}
|
||||
</a>
|
||||
</li>
|
||||
@ -103,12 +103,8 @@ export default {
|
||||
},
|
||||
logout() {
|
||||
this.$store.dispatch('logout')
|
||||
this.$router.push('/login')
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.$sidebar.showSidebar) {
|
||||
this.$sidebar.showSidebar = false
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -3,7 +3,6 @@ import DashboardPlugin from './plugins/dashboard-plugin'
|
||||
import App from './App.vue'
|
||||
import i18n from './i18n.js'
|
||||
import VeeValidate from './vee-validate.js'
|
||||
import VueCookies from 'vue-cookies'
|
||||
|
||||
// store
|
||||
import { store } from './store/store'
|
||||
@ -14,7 +13,14 @@ import router from './routes/router'
|
||||
// plugin setup
|
||||
Vue.use(DashboardPlugin)
|
||||
Vue.config.productionTip = false
|
||||
Vue.use(VueCookies)
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.requiresAuth && !store.state.session_id) {
|
||||
next({ path: '/login' })
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
/* eslint-disable no-new */
|
||||
new Vue({
|
||||
|
||||
@ -20,12 +20,4 @@ const router = new VueRouter({
|
||||
},
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
let language = to.params.lang
|
||||
if (!language) {
|
||||
language = 'de'
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
@ -1,29 +1,46 @@
|
||||
import NotFound from '@/views/NotFoundPage.vue'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
redirect: (to) => {
|
||||
return { path: '/login' }
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/overview',
|
||||
component: () => import('../views/KontoOverview.vue'),
|
||||
component: () => import('../views/Pages/KontoOverview.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/profile',
|
||||
name: 'Profile',
|
||||
component: () => import('../views/Pages/UserProfileCard.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/profileedit',
|
||||
component: () => import('../views/Pages/UserProfileEdit.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/activity',
|
||||
component: () => import('../views/Pages/UserProfileActivity.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/transactions',
|
||||
component: () => import('../views/Pages/UserProfileTransactionList.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
@ -39,12 +56,11 @@ const routes = [
|
||||
},
|
||||
{
|
||||
path: '/password',
|
||||
component: () => import('../views/Pages/Password.vue'),
|
||||
component: () => import('../views/Pages/ForgotPassword.vue'),
|
||||
},
|
||||
{
|
||||
path: '/explorer',
|
||||
name: 'Explorer',
|
||||
component: () => import('../views/Pages/Explorer.vue'),
|
||||
path: '/reset',
|
||||
component: () => import('../views/Pages/ResetPassword.vue'),
|
||||
},
|
||||
{ path: '*', component: NotFound },
|
||||
]
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
Vue.use(Vuex)
|
||||
import router from '../routes/router.js'
|
||||
import loginAPI from '../apis/loginAPI'
|
||||
import communityAPI from '../apis/communityAPI'
|
||||
import createPersistedState from 'vuex-persistedstate'
|
||||
|
||||
export const store = new Vuex.Store({
|
||||
plugins: [
|
||||
createPersistedState({
|
||||
storage: window.sessionStorage,
|
||||
}),
|
||||
],
|
||||
state: {
|
||||
session_id: null,
|
||||
email: '',
|
||||
language: 'en',
|
||||
sizeDE: 'normal',
|
||||
sizeGB: 'big',
|
||||
loginfail: false,
|
||||
user: {
|
||||
name: '',
|
||||
balance: 0,
|
||||
@ -31,98 +33,45 @@ export const store = new Vuex.Store({
|
||||
// Syncronous mutation of the state
|
||||
mutations: {
|
||||
language: (state, language) => {
|
||||
//console.log('mutation: language', language)
|
||||
state.language = language
|
||||
$cookies.set('gdd_lang', language)
|
||||
if (state.language == 'de') {
|
||||
state.sizeDE = 'big'
|
||||
state.sizeGB = 'normal'
|
||||
} else {
|
||||
state.sizeDE = 'normal'
|
||||
state.sizeGB = 'big'
|
||||
}
|
||||
},
|
||||
loginfail: (state, loginfail) => {
|
||||
//console.log('mutation: email')
|
||||
state.loginfail = loginfail
|
||||
},
|
||||
email: (state, email) => {
|
||||
//console.log('mutation: email')
|
||||
state.email = email
|
||||
},
|
||||
session_id: (state, session_id) => {
|
||||
//console.log('mutation: session_id')
|
||||
state.session_id = session_id
|
||||
},
|
||||
user_balance: (state, balance) => {
|
||||
//console.log('mutation: user_balance')
|
||||
state.user.balance = balance / 10000
|
||||
},
|
||||
user_balance_gdt: (state, balance) => {
|
||||
//console.log('mutation: user_balance_gdt')
|
||||
state.user.balance_gdt = balance / 10000
|
||||
},
|
||||
},
|
||||
// Asyncronous actions - used for api calls
|
||||
actions: {
|
||||
login: async ({ dispatch, commit }, data) => {
|
||||
const result = await loginAPI.login(data.email, data.password)
|
||||
if (result.success) {
|
||||
commit('session_id', result.result.data.session_id)
|
||||
commit('email', data.email)
|
||||
$cookies.set('gdd_session_id', result.result.data.session_id)
|
||||
$cookies.set('gdd_u', data.email)
|
||||
router.push('/overview')
|
||||
} else {
|
||||
// Register failed, we perform a logout
|
||||
//alert('>>>>> FAIl LOGIN')
|
||||
commit('loginfail', true)
|
||||
|
||||
//dispatch('logout')
|
||||
}
|
||||
},
|
||||
passwordReset: async (data) => {
|
||||
//console.log('<<<<<<<<<<< PASSWORT RESET TODO >>>>>>>>>>>', data.email)
|
||||
commit('session_id', data.session_id)
|
||||
commit('email', data.email)
|
||||
},
|
||||
passwordReset: async (data) => {},
|
||||
schoepfen: async (data) => {
|
||||
// http://localhost/transaction-creations/ajaxCreate
|
||||
},
|
||||
createUser: async ({ commit, dispatch }, data) => {
|
||||
// console.log('action: createUser')
|
||||
const result = await loginAPI.create(
|
||||
data.email,
|
||||
data.first_name,
|
||||
data.last_name,
|
||||
data.password,
|
||||
)
|
||||
if (result.success) {
|
||||
commit('session_id', result.result.data.session_id)
|
||||
commit('email', data.email)
|
||||
$cookies.set('gdd_session_id', result.result.data.session_id)
|
||||
$cookies.set('gdd_u', data.email)
|
||||
router.push('/overview')
|
||||
} else {
|
||||
// Register failed, we perform a logout
|
||||
// console.log('action createUser to logout start')
|
||||
dispatch('logout')
|
||||
}
|
||||
commit('session_id', data.session_id)
|
||||
commit('email', data.email)
|
||||
},
|
||||
logout: async ({ commit, state }) => {
|
||||
//console.log('action: logout')
|
||||
if (state.session_id) {
|
||||
const result = await loginAPI.logout(state.session_id)
|
||||
// The result can be error, but thats ok with us
|
||||
}
|
||||
|
||||
commit('session_id', null)
|
||||
commit('email', null)
|
||||
$cookies.remove('gdd_session_id')
|
||||
$cookies.remove('gdd_u')
|
||||
$cookies.remove('gdd_lang')
|
||||
router.push('/Login')
|
||||
sessionStorage.clear()
|
||||
},
|
||||
accountBalance: async ({ commit, dispatch, state }) => {
|
||||
const result = await communityAPI.balance($cookies.get('gdd_session_id'))
|
||||
const result = await communityAPI.balance(state.session_id)
|
||||
if (result.success) {
|
||||
commit('user_balance', result.result.data.balance)
|
||||
} else {
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
<li class="nav-item d-sm-none"></li>
|
||||
</b-navbar-nav>
|
||||
<b-navbar-nav class="align-items-center ml-auto ml-md-0">
|
||||
<a href="profile" class="pr-1" slot="title-container">
|
||||
<a class="pr-1" slot="title-container">
|
||||
<b-media no-body class="align-items-center">
|
||||
<span class="pb-2 text-lg font-weight-bold">
|
||||
{{ $store.state.email }}
|
||||
@ -66,8 +66,8 @@ export default {
|
||||
this.activeNotifications = false
|
||||
},
|
||||
logout() {
|
||||
//console.log("DashboardNavbar.vue user logout() : ")
|
||||
this.$store.dispatch('logout')
|
||||
this.$router.push('/login')
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
@ -26,17 +26,10 @@
|
||||
:placeholder="$t('form.email')"
|
||||
name="Email"
|
||||
:rules="{ required: true, email: true }"
|
||||
v-model="model.email"
|
||||
v-model="form.email"
|
||||
></base-input>
|
||||
{{ form }}
|
||||
<div class="text-center">
|
||||
<b-button
|
||||
type="submit"
|
||||
outline
|
||||
variant="secondary"
|
||||
class="mt-4"
|
||||
:disabled="disable"
|
||||
>
|
||||
<b-button type="submit" outline variant="secondary" class="mt-4">
|
||||
{{ $t('site.password.reset_now') }}
|
||||
</b-button>
|
||||
</div>
|
||||
@ -53,21 +46,26 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import loginAPI from '../../apis/loginAPI.js'
|
||||
|
||||
export default {
|
||||
name: 'password',
|
||||
data() {
|
||||
return {
|
||||
disable: 'disabled',
|
||||
model: {
|
||||
form: {
|
||||
email: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSubmit() {
|
||||
this.$store.dispatch('passwordReset', { email: this.model.email })
|
||||
this.model.email = ''
|
||||
this.$router.push('/thx')
|
||||
async onSubmit() {
|
||||
const result = await loginAPI.sendEmail(this.form.email)
|
||||
if (result.success) {
|
||||
this.$router.push({ path: '/thx', params: { id: 'resetmail' } })
|
||||
} else {
|
||||
alert(result.result)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import KontoOverview from './KontoOverview'
|
||||
import Vuex from 'vuex'
|
||||
import VueCookies from 'vue-cookies'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
@ -20,9 +20,9 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import GddStatus from './KontoOverview/GddStatus.vue'
|
||||
import GddSend from './KontoOverview/GddSend.vue'
|
||||
import GddTable from './KontoOverview/GddTable.vue'
|
||||
import GddStatus from '../KontoOverview/GddStatus.vue'
|
||||
import GddSend from '../KontoOverview/GddSend.vue'
|
||||
import GddTable from '../KontoOverview/GddTable.vue'
|
||||
|
||||
export default {
|
||||
name: 'Overview',
|
||||
@ -40,7 +40,7 @@ export default {
|
||||
GddTable,
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('accountBalance', $cookies.get('gdd_session_id'))
|
||||
this.$store.dispatch('accountBalance', this.$store.state.session_id)
|
||||
},
|
||||
methods: {
|
||||
setRows(rows) {
|
||||
@ -45,7 +45,7 @@
|
||||
v-model="model.password"
|
||||
></base-input>
|
||||
|
||||
<b-alert v-show="$store.state.loginfail" show variant="warning">
|
||||
<b-alert v-show="loginfail" show variant="warning">
|
||||
<span class="alert-text bv-example-row">
|
||||
<b-row>
|
||||
<b-col class="col-9 text-left">
|
||||
@ -89,12 +89,17 @@
|
||||
</router-link>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<b-col><router-link to="/reset">reset</router-link></b-col>
|
||||
</b-row>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</b-container>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import loginAPI from '../../apis/loginAPI'
|
||||
|
||||
export default {
|
||||
name: 'login',
|
||||
data() {
|
||||
@ -104,17 +109,24 @@ export default {
|
||||
password: '',
|
||||
// rememberMe: false
|
||||
},
|
||||
loginfail: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSubmit() {
|
||||
this.$store.dispatch('login', {
|
||||
email: this.model.email,
|
||||
password: this.model.password,
|
||||
})
|
||||
async onSubmit() {
|
||||
const result = await loginAPI.login(this.model.email, this.model.password)
|
||||
if (result.success) {
|
||||
this.$store.dispatch('login', {
|
||||
session_id: result.result.data.session_id,
|
||||
email: this.model.email,
|
||||
})
|
||||
this.$router.push('/overview')
|
||||
} else {
|
||||
this.loginfail = true
|
||||
}
|
||||
},
|
||||
closeAlert() {
|
||||
this.$store.state.loginfail = false
|
||||
this.loginfail = false
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -141,6 +141,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import loginAPI from '../../apis/loginAPI'
|
||||
|
||||
export default {
|
||||
name: 'register',
|
||||
data() {
|
||||
@ -167,19 +169,28 @@ export default {
|
||||
togglePasswordVisibility() {
|
||||
this.passwordVisible = !this.passwordVisible
|
||||
},
|
||||
onSubmit() {
|
||||
this.$store.dispatch('createUser', {
|
||||
email: this.model.email,
|
||||
first_name: this.model.firstname,
|
||||
last_name: this.model.lastname,
|
||||
emailType: 2,
|
||||
password: this.model.password,
|
||||
})
|
||||
this.model.email = ''
|
||||
this.model.firstname = ''
|
||||
this.model.lastname = ''
|
||||
this.model.password = ''
|
||||
this.$router.push('/thx')
|
||||
async onSubmit() {
|
||||
const result = await loginAPI.create(
|
||||
this.model.email,
|
||||
this.model.firstname,
|
||||
this.model.lastname,
|
||||
this.password,
|
||||
)
|
||||
if (result.success) {
|
||||
this.$store.dispatch('createUser', {
|
||||
session_id: result.result.data.session_id,
|
||||
email: this.model.email,
|
||||
})
|
||||
this.model.email = ''
|
||||
this.model.firstname = ''
|
||||
this.model.lastname = ''
|
||||
this.password = ''
|
||||
this.$router.push('/thx')
|
||||
} else {
|
||||
// todo: Display a proper error message!
|
||||
this.$store.dispatch('logout')
|
||||
this.$router.push('/login')
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
|
||||
107
frontend/src/views/Pages/ResetPassword.spec.js
Normal file
107
frontend/src/views/Pages/ResetPassword.spec.js
Normal file
@ -0,0 +1,107 @@
|
||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import flushPromises from 'flush-promises'
|
||||
|
||||
import ResetPassword from './ResetPassword'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
describe('ResetPassword', () => {
|
||||
let wrapper
|
||||
|
||||
let mocks = {
|
||||
$i18n: {
|
||||
locale: 'en',
|
||||
},
|
||||
$t: jest.fn((t) => t),
|
||||
}
|
||||
|
||||
let state = {
|
||||
// loginfail: false,
|
||||
}
|
||||
|
||||
let store = new Vuex.Store({
|
||||
state,
|
||||
})
|
||||
|
||||
let stubs = {
|
||||
RouterLink: RouterLinkStub,
|
||||
}
|
||||
|
||||
const Wrapper = () => {
|
||||
return mount(ResetPassword, { localVue, mocks, store, stubs })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('renders the Reset Password form', () => {
|
||||
expect(wrapper.find('div.resetpwd-form').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
//describe('Register header', () => {
|
||||
// it('has a welcome message', () => {
|
||||
// expect(wrapper.find('div.header').text()).toBe('site.signup.title site.signup.subtitle')
|
||||
// })
|
||||
//})
|
||||
|
||||
//describe('links', () => {
|
||||
// it('has a link "Back"', () => {
|
||||
// expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual('back')
|
||||
// })
|
||||
|
||||
// it('links to /login when clicking "Back"', () => {
|
||||
// expect(wrapper.findAllComponents(RouterLinkStub).at(0).props().to).toBe('/login')
|
||||
// })
|
||||
//})
|
||||
|
||||
//describe('Register form', () => {
|
||||
// it('has a register form', () => {
|
||||
// expect(wrapper.find('form').exists()).toBeTruthy()
|
||||
// })
|
||||
|
||||
// it('has 3 text input fields', () => {
|
||||
// expect(wrapper.findAll('input[type="text"]').length).toBe(3)
|
||||
// })
|
||||
|
||||
// it('has 2 password input fields', () => {
|
||||
// expect(wrapper.findAll('input[type="password"]').length).toBe(2)
|
||||
// })
|
||||
|
||||
// it('has 1 checkbox input fields', () => {
|
||||
// expect(wrapper.findAll('input[type="checkbox"]').length).toBe(1)
|
||||
// })
|
||||
|
||||
// it('has no submit button when not completely filled', () => {
|
||||
// expect(wrapper.find('button[type="submit"]').exists()).toBe(false)
|
||||
// })
|
||||
|
||||
// it('shows a warning when no valid Email is entered', async () => {
|
||||
// wrapper.findAll('input[type="text"]').at(2).setValue('no_valid@Email')
|
||||
// await flushPromises()
|
||||
// await expect(wrapper.find('.invalid-feedback').text()).toEqual(
|
||||
// 'The Email field must be a valid email',
|
||||
// )
|
||||
// })
|
||||
|
||||
// it('shows 4 warnings when no password is set', async () => {
|
||||
// const passwords = wrapper.findAll('input[type="password"]')
|
||||
// passwords.at(0).setValue('')
|
||||
// passwords.at(1).setValue('')
|
||||
// await flushPromises()
|
||||
// await expect(wrapper.find('div.hints').text()).toContain(
|
||||
// 'site.signup.lowercase',
|
||||
// 'site.signup.uppercase',
|
||||
// 'site.signup.minimum',
|
||||
// 'site.signup.one_number',
|
||||
// )
|
||||
// })
|
||||
|
||||
// //TODO test different invalid password combinations
|
||||
//})
|
||||
|
||||
// TODO test submit button
|
||||
})
|
||||
})
|
||||
147
frontend/src/views/Pages/ResetPassword.vue
Normal file
147
frontend/src/views/Pages/ResetPassword.vue
Normal file
@ -0,0 +1,147 @@
|
||||
<template>
|
||||
<div class="resetpwd-form">
|
||||
<!-- Header -->
|
||||
<div class="header p-4">
|
||||
<b-container class="container">
|
||||
<div class="header-body text-center mb-7">
|
||||
<b-row class="justify-content-center">
|
||||
<b-col xl="5" lg="6" md="8" class="px-2">
|
||||
<h1>Reset Password</h1>
|
||||
<div class="pb-4">
|
||||
Jetzt kannst du ein neues Passwort speichern, mit welchem du dich zukünfitg in der
|
||||
GRADIDO App anmelden kannst.
|
||||
</div>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</div>
|
||||
</b-container>
|
||||
</div>
|
||||
<!-- Page content -->
|
||||
<b-container class="mt--8 p-1">
|
||||
<!-- Table -->
|
||||
<b-row class="justify-content-center">
|
||||
<b-col lg="6" md="8">
|
||||
<b-card no-body class="border-0" style="background-color: #ebebeba3 !important">
|
||||
<b-card-body class="py-lg-4 px-sm-0 px-0 px-md-2 px-lg-4">
|
||||
<validation-observer v-slot="{ handleSubmit }" ref="formValidator">
|
||||
<b-form role="form" @submit.prevent="handleSubmit(onSubmit)">
|
||||
<b-form-group :label="$t('form.password')">
|
||||
<b-input-group>
|
||||
<b-form-input
|
||||
class="mb-0"
|
||||
v-model="password"
|
||||
name="password"
|
||||
:class="{ valid: passwordValidation.valid }"
|
||||
:type="passwordVisible ? 'text' : 'password'"
|
||||
prepend-icon="ni ni-lock-circle-open"
|
||||
:placeholder="$t('form.password')"
|
||||
></b-form-input>
|
||||
|
||||
<b-input-group-append>
|
||||
<b-button variant="outline-primary">
|
||||
<b-icon
|
||||
:icon="passwordVisible ? 'eye' : 'eye-slash'"
|
||||
@click="togglePasswordVisibility"
|
||||
/>
|
||||
</b-button>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
</b-form-group>
|
||||
|
||||
<base-input
|
||||
:label="$t('form.password_repeat')"
|
||||
type="password"
|
||||
name="password-repeat"
|
||||
:placeholder="$t('form.password_repeat')"
|
||||
prepend-icon="ni ni-lock-circle-open"
|
||||
v-model.lazy="checkPassword"
|
||||
:class="{ valid: passwordValidation.valid }"
|
||||
/>
|
||||
|
||||
<transition name="hint" appear>
|
||||
<div v-if="passwordValidation.errors.length > 0 && !submitted" class="hints">
|
||||
<ul>
|
||||
<li v-for="error in passwordValidation.errors" :key="error">
|
||||
<small>{{ error }}</small>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="matches" v-else-if="!samePasswords">
|
||||
<p>
|
||||
{{ $t('site.signup.dont_match') }}
|
||||
<i class="ni ni-active-40" color="danger"></i>
|
||||
</p>
|
||||
</div>
|
||||
</transition>
|
||||
<div
|
||||
class="text-center"
|
||||
v-if="passwordsFilled && samePasswords && passwordValidation.valid"
|
||||
>
|
||||
<b-button type="submit" variant="secondary" class="mt-4">
|
||||
{{ $t('signup') }}
|
||||
</b-button>
|
||||
</div>
|
||||
</b-form>
|
||||
</validation-observer>
|
||||
</b-card-body>
|
||||
</b-card>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</b-container>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'reset',
|
||||
data() {
|
||||
return {
|
||||
rules: [
|
||||
{ message: this.$t('site.signup.lowercase'), regex: /[a-z]+/ },
|
||||
{ message: this.$t('site.signup.uppercase'), regex: /[A-Z]+/ },
|
||||
{ message: this.$t('site.signup.minimum'), regex: /.{8,}/ },
|
||||
{ message: this.$t('site.signup.one_number'), regex: /[0-9]+/ },
|
||||
],
|
||||
password: '',
|
||||
checkPassword: '',
|
||||
passwordVisible: false,
|
||||
submitted: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
togglePasswordVisibility() {
|
||||
this.passwordVisible = !this.passwordVisible
|
||||
},
|
||||
onSubmit() {
|
||||
this.$store.dispatch('createUser', {
|
||||
password: this.model.password,
|
||||
})
|
||||
this.model.password = ''
|
||||
this.$router.push('/thx')
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
samePasswords() {
|
||||
return this.password === this.checkPassword
|
||||
},
|
||||
passwordsFilled() {
|
||||
return this.password !== '' && this.checkPassword !== ''
|
||||
},
|
||||
passwordValidation() {
|
||||
let errors = []
|
||||
for (let condition of this.rules) {
|
||||
if (!condition.regex.test(this.password)) {
|
||||
errors.push(condition.message)
|
||||
}
|
||||
}
|
||||
if (errors.length === 0) {
|
||||
return { valid: true, errors }
|
||||
}
|
||||
return { valid: false, errors }
|
||||
},
|
||||
},
|
||||
created() {
|
||||
//console.log('resetpage', this.$route)
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style></style>
|
||||
@ -11879,6 +11879,11 @@ shellwords@^0.1.1:
|
||||
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
|
||||
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
|
||||
|
||||
shvl@^2.0.2:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/shvl/-/shvl-2.0.3.tgz#eb4bd37644f5684bba1fc52c3010c96fb5e6afd1"
|
||||
integrity sha512-V7C6S9Hlol6SzOJPnQ7qzOVEWUQImt3BNmmzh40wObhla3XOYMe4gGiYzLrJd5TFa+cI2f9LKIRJTTKZSTbWgw==
|
||||
|
||||
sigmund@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590"
|
||||
@ -13244,11 +13249,6 @@ vue-clipboard2@^0.3.0:
|
||||
dependencies:
|
||||
clipboard "^2.0.0"
|
||||
|
||||
vue-cookies@^1.7.4:
|
||||
version "1.7.4"
|
||||
resolved "https://registry.yarnpkg.com/vue-cookies/-/vue-cookies-1.7.4.tgz#d241d0a0431da0795837651d10b4d73e7c8d3e8d"
|
||||
integrity sha512-mOS5Btr8V9zvAtkmQ7/TfqJIropOx7etDAgBywPCmHjvfJl2gFbH2XgoMghleLoyyMTi5eaJss0mPN7arMoslA==
|
||||
|
||||
vue-eslint-parser@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz#c268c96c6d94cfe3d938a5f7593959b0ca3360d1"
|
||||
@ -13406,6 +13406,14 @@ vue@^2.2.6, vue@^2.5.17, vue@^2.6.11:
|
||||
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.12.tgz#f5ebd4fa6bd2869403e29a896aed4904456c9123"
|
||||
integrity sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg==
|
||||
|
||||
vuex-persistedstate@^4.0.0-beta.3:
|
||||
version "4.0.0-beta.3"
|
||||
resolved "https://registry.yarnpkg.com/vuex-persistedstate/-/vuex-persistedstate-4.0.0-beta.3.tgz#89dd712de72d28e85cc95467d066002c1405f277"
|
||||
integrity sha512-T4IRD27qoUWh+8qr6T6zVp15xO7x/nPgnU13OD0C2uUwA7U9PhGozrj6lvVmMYDyRgc36J0msMXn3GvwHjkIhA==
|
||||
dependencies:
|
||||
deepmerge "^4.2.2"
|
||||
shvl "^2.0.2"
|
||||
|
||||
vuex@^3.6.0:
|
||||
version "3.6.2"
|
||||
resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.6.2.tgz#236bc086a870c3ae79946f107f16de59d5895e71"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user