Added password reset to the user list
This commit is contained in:
		| @@ -61,6 +61,16 @@ export function updateUser(data) { | |||||||
|   return axios.put(`${apiUrl}/user/${data.id}`, dto) |   return axios.put(`${apiUrl}/user/${data.id}`, dto) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | export function sendPasswordReset(email, type) { | ||||||
|  |   const dto = { | ||||||
|  |     email, | ||||||
|  |     type, | ||||||
|  |     platform: 'OLFDE' | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return axios.post(`${apiUrl}/user/password/send-reset-link`, dto) | ||||||
|  | } | ||||||
|  |  | ||||||
| function __dataToDTO(data) { | function __dataToDTO(data) { | ||||||
|   return { |   return { | ||||||
|     'firstName': data.firstName, |     'firstName': data.firstName, | ||||||
|   | |||||||
| @@ -36,13 +36,16 @@ | |||||||
|         </template> |         </template> | ||||||
|       </el-table-column> |       </el-table-column> | ||||||
|  |  | ||||||
|       <el-table-column align="center" label="Actions" width="120"> |       <el-table-column align="center" label="Actions" width="250"> | ||||||
|         <template slot-scope="scope"> |         <template slot-scope="scope"> | ||||||
|           <router-link :to="'/users/edit/' + scope.row.id"> |           <router-link :to="'/users/edit/' + scope.row.id"> | ||||||
|             <el-button type="primary" size="small" icon="el-icon-edit"> |             <el-button type="primary" size="small" icon="el-icon-edit"> | ||||||
|               Edit |               Edit | ||||||
|             </el-button> |             </el-button> | ||||||
|           </router-link> |           </router-link> | ||||||
|  |           <el-button type="primary" size="small" icon="el-icon-message" @click="sendPasswordResetConfirm(scope.row.email)"> | ||||||
|  |             Send PW Reset | ||||||
|  |           </el-button> | ||||||
|         </template> |         </template> | ||||||
|       </el-table-column> |       </el-table-column> | ||||||
|     </el-table> |     </el-table> | ||||||
| @@ -53,7 +56,7 @@ | |||||||
|  |  | ||||||
| <script> | <script> | ||||||
| const fetchAccountList = require('@/api/account').fetchList | const fetchAccountList = require('@/api/account').fetchList | ||||||
| import { fetchList } from '@/api/user' | import { fetchList, sendPasswordReset } from '@/api/user' | ||||||
| import Pagination from '@/components/Pagination' // Secondary package based on el-pagination | import Pagination from '@/components/Pagination' // Secondary package based on el-pagination | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
| @@ -110,6 +113,30 @@ export default { | |||||||
|     handleFilter(query) { |     handleFilter(query) { | ||||||
|       this.listQuery.page = 1 |       this.listQuery.page = 1 | ||||||
|       this.getList() |       this.getList() | ||||||
|  |     }, | ||||||
|  |     sendPasswordResetConfirm(email) { | ||||||
|  |       this.$confirm(`This will send an email to <b>${email}</b>, prompting them to reset their password with the provided link. Are you sure you want to do this?`, 'Warning', { | ||||||
|  |         confirmButtonText: 'Proceed', | ||||||
|  |         cancelButtonText: 'Cancel', | ||||||
|  |         dangerouslyUseHTMLString: true, | ||||||
|  |         type: 'warning' | ||||||
|  |       }).then(() => { | ||||||
|  |         sendPasswordReset(email, 'RESET').then(() => { | ||||||
|  |           // Send the request | ||||||
|  |           this.$message({ | ||||||
|  |             type: 'success', | ||||||
|  |             message: 'Password Reset Sent' | ||||||
|  |           }) | ||||||
|  |         }).catch(() => { | ||||||
|  |           // Send the request | ||||||
|  |           this.$message({ | ||||||
|  |             type: 'danger', | ||||||
|  |             message: 'Password Reset Failed' | ||||||
|  |           }) | ||||||
|  |         }) | ||||||
|  |       }).catch(() => { | ||||||
|  |         // Do nothing, we don't care that they clicked cancel, but if we don't catch it, we get a console error | ||||||
|  |       }) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user