Skip to content

Commit

Permalink
Merge pull request #39 from mekanix/feature/registration
Browse files Browse the repository at this point in the history
Feature/registration
  • Loading branch information
mekanix authored Mar 10, 2020
2 parents 4c50275 + 738000e commit 78697e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions freenit/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def post(self, args):
}
host = request.headers.get('Origin', request.url_root)
requestToken = create_access_token(identity, expires_delta=expires)
url = f'{host}/confirm/{requestToken}'
confirm = 'confirm'
if host[:-1] != '/':
confirm = f'/{confirm}'
url = f'{host}{confirm}/{requestToken}'
msg = MIMEText(url, 'plain', 'utf-8')
config = current_app.config
subject = config['SUBJECTS']['prefix'] + config['SUBJECTS']['register']
Expand All @@ -155,7 +158,7 @@ def post(self, args):
class AuthRegisterConfirmAPI(MethodView):
@blueprint.response(UserSchema)
def get(self, token):
"""Register new user"""
"""Confirm new user"""
decoded_token = decode_token(token)
identity = decoded_token['identity']
User = current_app.user_datastore.user_model
Expand Down Expand Up @@ -200,9 +203,11 @@ def post(self, args):
url = f'{host}/reset/{resetToken}'
msg = MIMEText(url, 'plain', 'utf-8')
msg['From'] = 'office@example.com'
msg['Subject'] = 'Freenit message'
to = ['meka@tilda.center']
current_app.sendmail(to, msg)
subjects = current_app.config['SUBJECTS']
subject = subjects['prefix'] + subjects['register']
msg['Subject'] = subject
msg['To'] = user.email
current_app.sendmail(msg)
except User.DoesNotExist:
pass
return {}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='freenit',
version='0.0.27',
version='0.0.28',
description='REST API framework based on Flask-Smorest',
long_description=README,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 78697e9

Please sign in to comment.