Skip to content

Commit 07359db

Browse files
authored
Merge pull request #269 from Seluj78/232-reset-password-view
232 reset password view
2 parents 16ebd1c + 207b81e commit 07359db

File tree

16 files changed

+250
-17
lines changed

16 files changed

+250
-17
lines changed

backend/PyMatcha/routes/api/auth/password.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def reset_password():
9999
def check_token_validity():
100100
data = request.get_json()
101101
try:
102-
confirm_token(data["token"], expiration=7200)
102+
email, token_type = confirm_token(data["token"], expiration=7200)
103103
except (SignatureExpired, BadSignature) as e:
104104
if e == SignatureExpired:
105105
current_app.logger.debug("/auth/password/reset -> Signature Expired")
@@ -108,4 +108,12 @@ def check_token_validity():
108108
current_app.logger.debug("/auth/password/reset -> Bad Signature")
109109
raise BadRequestError("Bad Signature.", "Request another password reset and try again.")
110110
else:
111+
try:
112+
u = get_user(email)
113+
except NotFoundError:
114+
current_app.logger.debug("/auth/password/reset -> User not found")
115+
raise NotFoundError("User not found.")
116+
if u.previous_reset_token == data["token"]:
117+
current_app.logger.debug("/auth/password/reset -> Token already used")
118+
raise BadRequestError("Token already used", "Please request a new one.")
111119
return Success("Reset token is correct")

backend/schemas/swagger.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,8 @@ paths:
10501050
required: true
10511051
example: qwERg3rtyhog23mrweof5ngib4j3ktnrvwefqjskldnakms
10521052
responses:
1053+
"404":
1054+
$ref: '#/components/responses/NotFound'
10531055
"400":
10541056
$ref: '#/components/responses/BadRequest'
10551057
"200":

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@sentry/browser": "^5.24.2",
1212
"@sentry/integrations": "^5.24.2",
1313
"@sentry/tracing": "^5.24.2",
14+
"axios": "^0.20.0",
1415
"core-js": "^3.6.5",
1516
"tailwindcss": "^1.8.10",
1617
"vee-validate": "^3.3.11",

frontend/src/assets/auth/error.png

133 KB
Loading
116 KB
Loading
125 KB
Loading

frontend/src/assets/css/tailwind.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,22 @@
115115
@apply items-center;
116116
}
117117

118+
.auth-sub-container-error {
119+
@apply bg-red-500;
120+
@apply p-4;
121+
@apply flex;
122+
@apply justify-center;
123+
@apply text-center;
124+
@apply rounded-md;
125+
@apply max-w-sm;
126+
@apply w-full;
127+
}
128+
129+
.auth-sub-container-error-message {
130+
@apply text-white-matcha;
131+
@apply text-xl;
132+
}
133+
118134
.auth-sub-container-content-heading {
119135
@apply text-base;
120136
@apply font-bold;
@@ -150,6 +166,10 @@
150166
@apply mt-4;
151167
}
152168

169+
.auth-sub-container-content-submit-button:active, .auth-sub-container-content-submit-button:focus {
170+
outline: none;
171+
}
172+
153173
.auth-sub-container-content-button {
154174
@apply bg-purple-matcha;
155175
@apply w-full;

frontend/src/main.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import Vue from 'vue';
22
import { ValidationProvider, ValidationObserver, extend } from 'vee-validate/dist/vee-validate.full.esm';
3+
import * as Sentry from '@sentry/browser';
4+
import { Vue as VueIntegration } from '@sentry/integrations';
5+
import { Integrations } from '@sentry/tracing';
6+
import http from './plugins/http';
7+
import errorMessenger from './plugins/errorMessenger';
38
import App from './App.vue';
49
import router from './router';
510
import store from './store';
611
import validPassword from './validators/validPassword';
712
import './assets/css/tailwind.css';
813

9-
import * as Sentry from "@sentry/browser";
10-
import { Vue as VueIntegration } from "@sentry/integrations";
11-
import { Integrations } from "@sentry/tracing";
12-
1314
Sentry.init({
14-
dsn: "https://fc31e918801742e2b1e691067496e257@o450203.ingest.sentry.io/5434440",
15+
dsn: 'https://fc31e918801742e2b1e691067496e257@o450203.ingest.sentry.io/5434440',
1516
integrations: [
1617
new VueIntegration({
1718
Vue,
@@ -28,6 +29,9 @@ extend('validPassword', validPassword);
2829

2930
Vue.config.productionTip = false;
3031

32+
Vue.use(http);
33+
Vue.use(errorMessenger);
34+
3135
new Vue({
3236
router,
3337
store,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Vue from 'vue';
2+
3+
export default {
4+
install() {
5+
Vue.prototype.$errorMessenger = (error) => {
6+
if (error.response && error.response.status === 404) {
7+
return 'Something went wrong on our end. We will fix it soon. Please, try again later';
8+
}
9+
return error.response.data.error.message;
10+
};
11+
},
12+
};

frontend/src/plugins/http.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Axios from 'axios';
2+
import Vue from 'vue';
3+
4+
function createAxiosInstance(baseURL) {
5+
return Axios.create({
6+
baseURL,
7+
headers: {
8+
'Content-Type': 'application/json',
9+
Authorization: `Bearer ${localStorage.token}`,
10+
},
11+
});
12+
}
13+
14+
const axiosInstance = createAxiosInstance(process.env.VUE_APP_BACKEND_BASE_URL);
15+
16+
export default {
17+
install() {
18+
Vue.prototype.$http = axiosInstance;
19+
},
20+
};

0 commit comments

Comments
 (0)