mayureshagashe2105 commited on
Commit
1f640f4
·
1 Parent(s): b7bbf23

smtp relay to port 2525

Browse files
TechdocsAPI/backend/services/auth/ops.py CHANGED
@@ -61,13 +61,13 @@ async def ops_signup(bgtasks: BackgroundTasks, response_result: GeneralResponse,
61
 
62
 
63
 
64
- DBQueries.insert_to_database('auth', (data.username, Auth.get_password_hash(data.password), data.email, 1),
65
  ['username', 'password', 'email', 'is_verified'])
66
 
67
 
68
 
69
  response_result.status = 'success'
70
- # response_result.message = [f'Activate your account by clicking on the link sent to {data.email}.\nMake sure to check your spam folder.']
71
 
72
  def ops_login(data:LoginCreds):
73
  """Wrapper method to handle login process.
@@ -96,8 +96,8 @@ def ops_login(data:LoginCreds):
96
  # password is incorrect
97
  raise InvalidCredentialsException(response_result)
98
 
99
- # if not user[2]:
100
- # raise EmailNotVerifiedException()
101
 
102
  # password is correct
103
  return TokenSchema(access_token=Auth.create_access_token(data.username),
@@ -166,7 +166,6 @@ def ops_verify_email(request: Request, response_result: GeneralResponse, token:s
166
  print(registered_email[0][0])
167
  if registered_email[0][0]:
168
  return app.state.templates.TemplateResponse("verification_failure.html", context={"request": request})
169
- print("after")
170
 
171
  DBQueries.update_data_in_database('auth','is_verified',f"username='{username}'", (True,))
172
  DBQueries.update_data_in_database('auth','email',f"username='{username}'", email)
 
61
 
62
 
63
 
64
+ DBQueries.insert_to_database('auth', (data.username, Auth.get_password_hash(data.password), "", 0),
65
  ['username', 'password', 'email', 'is_verified'])
66
 
67
 
68
 
69
  response_result.status = 'success'
70
+ response_result.message = [f'Activate your account by clicking on the link sent to {data.email}.\nMake sure to check your spam folder.']
71
 
72
  def ops_login(data:LoginCreds):
73
  """Wrapper method to handle login process.
 
96
  # password is incorrect
97
  raise InvalidCredentialsException(response_result)
98
 
99
+ if not user[2]:
100
+ raise EmailNotVerifiedException()
101
 
102
  # password is correct
103
  return TokenSchema(access_token=Auth.create_access_token(data.username),
 
166
  print(registered_email[0][0])
167
  if registered_email[0][0]:
168
  return app.state.templates.TemplateResponse("verification_failure.html", context={"request": request})
 
169
 
170
  DBQueries.update_data_in_database('auth','is_verified',f"username='{username}'", (True,))
171
  DBQueries.update_data_in_database('auth','email',f"username='{username}'", email)
TechdocsAPI/backend/templates/email_verification.html ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Verify Email</title>
5
+ <style>
6
+ body {
7
+ font-family: Arial, sans-serif;
8
+ background-color: #f4f4f4;
9
+ margin: 0;
10
+ padding: 0;
11
+ }
12
+
13
+ .container {
14
+ width: 80%;
15
+ margin: 0 auto;
16
+ padding: 20px;
17
+ background-color: #fff;
18
+ border-radius: 8px;
19
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
20
+ }
21
+
22
+ h3 {
23
+ color: #333;
24
+ text-align: center;
25
+ }
26
+
27
+ p {
28
+ color: #555;
29
+ text-align: center;
30
+ margin-bottom: 20px;
31
+ }
32
+
33
+ a.button {
34
+ display: block;
35
+ width: 50%;
36
+ margin: 20px auto;
37
+ padding: 12px;
38
+ border-radius: 5px;
39
+ text-align: center;
40
+ text-decoration: none;
41
+ background-color: #0275d8;
42
+ color: #fff;
43
+ font-size: 1rem;
44
+ transition: background-color 0.3s;
45
+ }
46
+
47
+ a.button:hover {
48
+ background-color: #025aa5;
49
+ }
50
+
51
+ .disclaimer {
52
+ color: #777;
53
+ text-align: center;
54
+ }
55
+ </style>
56
+ </head>
57
+ <body>
58
+ <div class="container">
59
+ <h3>Account Verification</h3>
60
+
61
+ <p>Hi, {{username}}👋. Thank you for registering with Techdocs. Please click the button below to verify your account:</p>
62
+
63
+ <a class="button" href="{{verify_link}}" target="_blank">Verify your email</a>
64
+
65
+ <p class="disclaimer">Please disregard this email if you did not register with Techdocs. Thank you.</p>
66
+ </div>
67
+ </body>
68
+ </html>