def reset_request(self): """Sends a reset password email""" schema = RELS['v1.AuthView:reset'][request.method] args = request_reset_password_options.parse_args() email = args.get('email') user = User.find(email=email).first() if not user: return dict(status=409, message="Invalid email address"), 409 token = generate_reset_password_token(user) reset_link = urljoin(current_app.config['CLIENT_DOMAIN'], '/#/reset/'+token) #TODO this mail send should be performed asynchronously using celery, see issue #88850472 send_message( subject='FogMine Reset Request', sender="*****@*****.**", recipients = [user.email], html_body=render_template('email/reset.html', user=user, reset_link=reset_link), text_body=render_template('email/reset.txt', user=user, reset_link=reset_link) ) return dict(status=200, message="Reset instructions sent")
def test_confirm_user(self, apidb, testapi, mail, role, invite): m = self.test_register_user_sends_confirmation_email(apidb, testapi, mail, role, invite=invite) u = User.find(email='*****@*****.**').first() u.confirmed_at.should.be.none token = self.get_confirmation_token_from_email(m) href = url_for('v1.AuthView:confirm_email') resp = testapi.post_json(href, dict(token=token)) # confirmed status should be set u.confirmed_at.should_not.be.none # confirmed user should receive a login credential set resp.status_code.should.equal(200) resp.json.get('user').should_not.be.none