@@ -140,7 +140,10 @@ def post(self, args):
140
140
}
141
141
host = request .headers .get ('Origin' , request .url_root )
142
142
requestToken = create_access_token (identity , expires_delta = expires )
143
- url = f'{ host } /confirm/{ requestToken } '
143
+ confirm = 'confirm'
144
+ if host [:- 1 ] != '/' :
145
+ confirm = f'/{ confirm } '
146
+ url = f'{ host } { confirm } /{ requestToken } '
144
147
msg = MIMEText (url , 'plain' , 'utf-8' )
145
148
config = current_app .config
146
149
subject = config ['SUBJECTS' ]['prefix' ] + config ['SUBJECTS' ]['register' ]
@@ -155,7 +158,7 @@ def post(self, args):
155
158
class AuthRegisterConfirmAPI (MethodView ):
156
159
@blueprint .response (UserSchema )
157
160
def get (self , token ):
158
- """Register new user"""
161
+ """Confirm new user"""
159
162
decoded_token = decode_token (token )
160
163
identity = decoded_token ['identity' ]
161
164
User = current_app .user_datastore .user_model
@@ -200,9 +203,11 @@ def post(self, args):
200
203
url = f'{ host } /reset/{ resetToken } '
201
204
msg = MIMEText (url , 'plain' , 'utf-8' )
202
205
msg ['From' ] = 'office@example.com'
203
- msg ['Subject' ] = 'Freenit message'
204
- to = ['meka@tilda.center' ]
205
- current_app .sendmail (to , msg )
206
+ subjects = current_app .config ['SUBJECTS' ]
207
+ subject = subjects ['prefix' ] + subjects ['register' ]
208
+ msg ['Subject' ] = subject
209
+ msg ['To' ] = user .email
210
+ current_app .sendmail (msg )
206
211
except User .DoesNotExist :
207
212
pass
208
213
return {}
0 commit comments