def post(self): req_parser = reqparse.RequestParser() req_parser.add_argument('email', type=str, required=True) args = req_parser.parse_args() LOGGER.debug( "Requesting password reset for email {} and organisation {}". format(args['email'], g.organisation.name)) user = user_repository.get_by_email(args['email'], g.organisation.id) if not user: LOGGER.debug( "No user found for email {} and organisation {}".format( args['email'], g.organisation.name)) return USER_NOT_FOUND password_reset = PasswordReset(user=user) db.session.add(password_reset) db.session.commit() email_user( 'password-reset', template_parameters=dict(system=g.organisation.system_name, organisation=g.organisation.name, host=misc.get_baobab_host(), token=password_reset.code), subject_parameters=dict(system_name=g.organisation.system_name), user=user) return {}, 201
def post(self): req_parser = reqparse.RequestParser() req_parser.add_argument('email', type=str, required=True) args = req_parser.parse_args() LOGGER.debug("Requesting password reset for email {}".format( args['email'])) user = db.session.query(AppUser).filter( AppUser.email == args['email']).first() if not user: LOGGER.debug("No user found for email {}".format(args['email'])) return USER_NOT_FOUND password_reset = PasswordReset(user=user) db.session.add(password_reset) db.session.commit() # send_mail(recipient=args['email'], # subject='Password Reset for Lytehouse portal', # body_text=RESET_EMAIL_BODY.format(user.firstname, user.lastname, # get_baobab_host(), password_reset.code)) return {}, 201
def post(self): req_parser = reqparse.RequestParser() req_parser.add_argument('email', type=str, required=True) args = req_parser.parse_args() user = db.session.query(AppUser).filter(AppUser.email==args['email']).first() if user: password_reset = PasswordReset(user=user) db.session.add(password_reset) db.session.commit() # TODO: Send the email using any preferred method return {}, 201
def post(self): args = self.req_parser.parse_args() user_api = UserAPI.UserAPI() user, status = user_api.post(invitedGuest=True) if status != 201: return user, status invited_guest_api = InvitedGuestAPI() invited_guest_info, status = invited_guest_api.post(send_email=False) if status == 201: event_id = invited_guest_info['event_id'] role = invited_guest_info['role'] user = user_repository.get_by_id(user['id']) event = event_repository.get_by_id(event_id) reset_code = misc.make_code() password_reset = PasswordReset(user=user) db.session.add(password_reset) db.session.commit() try: send_mail(recipient=user.email, subject='Your invitation to {}'.format(event.name), body_text=NEW_GUEST_EMAIL_TEMPLATE.format( user_title=user.user_title, firstname=user.firstname, lastname=user.lastname, role=role, event_name=event.name, event_key=event.key, system_name=g.organisation.system_name, host=misc.get_baobab_host(), reset_code=password_reset.code)) except Exception as e: LOGGER.error( 'Failed to send email for invited guest with user Id {} due to: {}' .format(user.id, e)) return INVITED_GUEST_EMAIL_FAILED return invited_guest_info, status
def post(self): args = self.req_parser.parse_args() user_api = UserAPI.UserAPI() user, status = user_api.post(invitedGuest=True) if status != 201: return user, status invited_guest_api = InvitedGuestAPI() invited_guest_info, status = invited_guest_api.post(send_email=False) if status == 201: event_id = invited_guest_info['event_id'] role = invited_guest_info['role'] user = user_repository.get_by_id(user['id']) event = event_repository.get_by_id(event_id) reset_code = misc.make_code() password_reset=PasswordReset(user=user) db.session.add(password_reset) db.session.commit() try: email_user( 'new-guest-registration' if event.is_registration_open else 'new-guest-no-registration', template_parameters=dict( event_key=event.key, system_name=g.organisation.system_name, host=misc.get_baobab_host(), role=role, reset_code=password_reset.code, ), event=event, user=user ) except Exception as e: LOGGER.error('Failed to send email for invited guest with user Id {} due to: {}'.format(user.id, e)) return INVITED_GUEST_EMAIL_FAILED return invited_guest_info, status
def post(self): req_parser = reqparse.RequestParser() req_parser.add_argument('email', type=str, required=True) args = req_parser.parse_args() LOGGER.debug( "Requesting password reset for email {} and organisation {}". format(args['email'], g.organisation.name)) user = user_repository.get_by_email(args['email'], g.organisation.id) if not user: LOGGER.debug( "No user found for email {} and organisation {}".format( args['email'], g.organisation.name)) return USER_NOT_FOUND password_reset = PasswordReset(user=user) db.session.add(password_reset) db.session.commit() send_mail(recipient=args['email'], sender_name=g.organisation.name, sender_email=g.organisation.email_from, subject='Password Reset for {}'.format( g.organisation.system_name), body_text=RESET_EMAIL_BODY.format( title=user.user_title, firstname=user.firstname, lastname=user.lastname, system=g.organisation.system_name, organisation=g.organisation.name, host=misc.get_baobab_host(), token=password_reset.code)) return {}, 201