2664: Fix the bug reported by fastlorenzo r=mergify[bot] a=nextgens

## What type of PR?

bug-fix

## What does this PR do?

Fix the bug reported by fastlorenzo: when using proxy-auth, if the user doesn't exist you have to hit the URL twice.

### Related issue(s)


## Prerequisites
Before we can consider review and merge, please make sure the following list is done and checked.
If an entry in not applicable, you can check it or remove it from the list.

- [ ] In case of feature or enhancement: documentation updated accordingly
- [ ] Unless it's docs or a minor change: add [changelog](https://mailu.io/master/contributors/workflow.html#changelog) entry file.


Co-authored-by: Florent Daigniere <nextgens@freenetproject.org>
main
bors[bot] 2 years ago committed by GitHub
commit 0de2430868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,7 +62,6 @@ def logout():
response.set_cookie(cookie, 'empty', expires=0) response.set_cookie(cookie, 'empty', expires=0)
return response return response
@sso.route('/proxy', methods=['GET']) @sso.route('/proxy', methods=['GET'])
@sso.route('/proxy/<target>', methods=['GET']) @sso.route('/proxy/<target>', methods=['GET'])
def proxy(target='webmail'): def proxy(target='webmail'):
@ -97,6 +96,8 @@ def proxy(target='webmail'):
user.set_password(secrets.token_urlsafe()) user.set_password(secrets.token_urlsafe())
models.db.session.add(user) models.db.session.add(user)
models.db.session.commit() models.db.session.commit()
flask.session.regenerate()
flask_login.login_user(user)
user.send_welcome() user.send_welcome()
flask.current_app.logger.info(f'Login succeeded by proxy created user: {user} from {client_ip} through {flask.request.remote_addr}.') flask.current_app.logger.info(f'Login succeeded by proxy created user: {user} from {client_ip} through {flask.request.remote_addr}.')
return flask.redirect(app.config['WEB_ADMIN'] if target=='admin' else app.config['WEB_WEBMAIL']) return flask.redirect(app.config['WEB_ADMIN'] if target=='admin' else app.config['WEB_WEBMAIL'])

Loading…
Cancel
Save