2022-04-14 18:46:11 +02:00
|
|
|
from typing import Optional
|
|
|
|
|
2021-01-08 18:53:01 +01:00
|
|
|
import arrow
|
2022-03-10 16:13:31 +01:00
|
|
|
import sqlalchemy
|
2022-04-14 18:46:11 +02:00
|
|
|
from flask_admin.model.template import EndpointLinkRowAction
|
|
|
|
from markupsafe import Markup
|
2022-03-14 15:28:53 +01:00
|
|
|
|
2022-04-14 18:46:11 +02:00
|
|
|
from app import models, s3
|
|
|
|
from flask import redirect, url_for, request, flash, Response
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 09:20:12 +02:00
|
|
|
from flask_admin import expose, AdminIndexView
|
2021-01-08 18:53:01 +01:00
|
|
|
from flask_admin.actions import action
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 09:20:12 +02:00
|
|
|
from flask_admin.contrib import sqla
|
2022-02-28 16:40:07 +01:00
|
|
|
from flask_login import current_user
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 09:20:12 +02:00
|
|
|
|
2021-10-12 14:36:47 +02:00
|
|
|
from app.db import Session
|
2022-03-10 16:13:31 +01:00
|
|
|
from app.models import (
|
|
|
|
User,
|
|
|
|
ManualSubscription,
|
|
|
|
Fido,
|
|
|
|
Subscription,
|
|
|
|
AppleSubscription,
|
|
|
|
AdminAuditLog,
|
2022-03-11 11:37:14 +01:00
|
|
|
AuditLogActionEnum,
|
2022-04-25 14:40:42 +02:00
|
|
|
ProviderComplaintState,
|
2022-04-14 18:46:11 +02:00
|
|
|
Phase,
|
2022-04-25 14:40:42 +02:00
|
|
|
ProviderComplaint,
|
2022-07-04 11:05:13 +02:00
|
|
|
Alias,
|
2022-07-22 11:24:53 +02:00
|
|
|
Newsletter,
|
2022-08-04 09:20:07 +02:00
|
|
|
PADDLE_SUBSCRIPTION_GRACE_DAYS,
|
2022-03-10 16:13:31 +01:00
|
|
|
)
|
2022-07-22 11:24:53 +02:00
|
|
|
from app.newsletter_utils import send_newsletter_to_user, send_newsletter_to_address
|
2021-01-08 18:53:01 +01:00
|
|
|
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 09:20:12 +02:00
|
|
|
|
|
|
|
class SLModelView(sqla.ModelView):
|
2021-01-08 18:53:01 +01:00
|
|
|
column_default_sort = ("id", True)
|
2021-01-11 12:04:37 +01:00
|
|
|
column_display_pk = True
|
2022-12-13 16:58:27 +01:00
|
|
|
page_size = 100
|
2021-01-08 18:53:01 +01:00
|
|
|
|
|
|
|
can_edit = False
|
|
|
|
can_create = False
|
|
|
|
can_delete = False
|
|
|
|
edit_modal = True
|
|
|
|
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 09:20:12 +02:00
|
|
|
def is_accessible(self):
|
|
|
|
return current_user.is_authenticated and current_user.is_admin
|
|
|
|
|
|
|
|
def inaccessible_callback(self, name, **kwargs):
|
|
|
|
# redirect to login page if user doesn't have access
|
|
|
|
return redirect(url_for("auth.login", next=request.url))
|
|
|
|
|
2022-03-10 16:13:31 +01:00
|
|
|
def on_model_change(self, form, model, is_created):
|
|
|
|
changes = {}
|
|
|
|
for attr in sqlalchemy.inspect(model).attrs:
|
|
|
|
if attr.history.has_changes() and attr.key not in (
|
|
|
|
"created_at",
|
|
|
|
"updated_at",
|
|
|
|
):
|
|
|
|
value = attr.value
|
2022-03-10 16:37:21 +01:00
|
|
|
# If it's a model reference, get the source id
|
2022-03-10 16:13:31 +01:00
|
|
|
if issubclass(type(value), models.Base):
|
|
|
|
value = value.id
|
2022-03-10 16:37:21 +01:00
|
|
|
# otherwise, if its a generic object stringify it
|
|
|
|
if issubclass(type(value), object):
|
|
|
|
value = str(value)
|
2022-03-10 16:13:31 +01:00
|
|
|
changes[attr.key] = value
|
2022-03-10 16:37:21 +01:00
|
|
|
auditAction = (
|
2022-03-11 11:37:14 +01:00
|
|
|
AuditLogActionEnum.create_object
|
2022-03-10 16:37:21 +01:00
|
|
|
if is_created
|
2022-03-11 11:37:14 +01:00
|
|
|
else AuditLogActionEnum.update_object
|
2022-03-10 16:37:21 +01:00
|
|
|
)
|
2022-03-10 16:13:31 +01:00
|
|
|
AdminAuditLog.create(
|
|
|
|
admin_user_id=current_user.id,
|
|
|
|
model=model.__class__.__name__,
|
|
|
|
model_id=model.id,
|
2022-03-14 15:07:51 +01:00
|
|
|
action=auditAction.value,
|
2022-03-10 16:13:31 +01:00
|
|
|
data=changes,
|
|
|
|
)
|
|
|
|
|
|
|
|
def on_model_delete(self, model):
|
|
|
|
AdminAuditLog.create(
|
|
|
|
admin_user_id=current_user.id,
|
|
|
|
model=model.__class__.__name__,
|
|
|
|
model_id=model.id,
|
2022-03-14 15:07:51 +01:00
|
|
|
action=AuditLogActionEnum.delete_object.value,
|
2022-03-10 16:13:31 +01:00
|
|
|
)
|
|
|
|
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 09:20:12 +02:00
|
|
|
|
|
|
|
class SLAdminIndexView(AdminIndexView):
|
|
|
|
@expose("/")
|
|
|
|
def index(self):
|
|
|
|
if not current_user.is_authenticated or not current_user.is_admin:
|
|
|
|
return redirect(url_for("auth.login", next=request.url))
|
|
|
|
|
2021-01-12 18:14:21 +01:00
|
|
|
return redirect("/admin/user")
|
2021-01-08 18:53:01 +01:00
|
|
|
|
|
|
|
|
2022-09-02 10:39:53 +02:00
|
|
|
def _user_upgrade_channel_formatter(view, context, model, name):
|
|
|
|
return Markup(model.upgrade_channel)
|
|
|
|
|
|
|
|
|
2021-01-08 18:53:01 +01:00
|
|
|
class UserAdmin(SLModelView):
|
|
|
|
column_searchable_list = ["email", "id"]
|
|
|
|
column_exclude_list = [
|
|
|
|
"salt",
|
|
|
|
"password",
|
|
|
|
"otp_secret",
|
|
|
|
"last_otp",
|
|
|
|
"fido_uuid",
|
|
|
|
"profile_picture",
|
|
|
|
]
|
2022-03-02 19:04:30 +01:00
|
|
|
can_edit = False
|
2021-01-08 18:53:01 +01:00
|
|
|
|
|
|
|
def scaffold_list_columns(self):
|
|
|
|
ret = super().scaffold_list_columns()
|
|
|
|
ret.insert(0, "upgrade_channel")
|
|
|
|
return ret
|
|
|
|
|
2022-09-02 10:39:53 +02:00
|
|
|
column_formatters = {
|
|
|
|
"upgrade_channel": _user_upgrade_channel_formatter,
|
|
|
|
}
|
|
|
|
|
2022-11-28 10:39:18 +01:00
|
|
|
@action(
|
|
|
|
"disable_user",
|
|
|
|
"Disable user",
|
|
|
|
"Are you sure you want to disable the selected users?",
|
|
|
|
)
|
|
|
|
def action_disable_user(self, ids):
|
|
|
|
for user in User.filter(User.id.in_(ids)):
|
|
|
|
user.disabled = True
|
|
|
|
|
|
|
|
flash(f"Disabled user {user.id}")
|
|
|
|
AdminAuditLog.disable_user(current_user.id, user.id)
|
|
|
|
|
|
|
|
Session.commit()
|
|
|
|
|
|
|
|
@action(
|
|
|
|
"enable_user",
|
|
|
|
"Enable user",
|
|
|
|
"Are you sure you want to enable the selected users?",
|
|
|
|
)
|
|
|
|
def action_enable_user(self, ids):
|
|
|
|
for user in User.filter(User.id.in_(ids)):
|
|
|
|
user.disabled = False
|
|
|
|
|
|
|
|
flash(f"Enabled user {user.id}")
|
|
|
|
AdminAuditLog.enable_user(current_user.id, user.id)
|
|
|
|
|
|
|
|
Session.commit()
|
|
|
|
|
2021-01-08 18:53:01 +01:00
|
|
|
@action(
|
|
|
|
"education_upgrade",
|
|
|
|
"Education upgrade",
|
|
|
|
"Are you sure you want to edu-upgrade selected users?",
|
|
|
|
)
|
|
|
|
def action_edu_upgrade(self, ids):
|
2021-03-26 12:14:33 +01:00
|
|
|
manual_upgrade("Edu", ids, is_giveaway=True)
|
2021-01-08 18:53:01 +01:00
|
|
|
|
2021-02-03 18:54:42 +01:00
|
|
|
@action(
|
|
|
|
"charity_org_upgrade",
|
|
|
|
"Charity Organization upgrade",
|
|
|
|
"Are you sure you want to upgrade selected users using the Charity organization program?",
|
|
|
|
)
|
|
|
|
def action_charity_org_upgrade(self, ids):
|
2021-03-26 12:14:33 +01:00
|
|
|
manual_upgrade("Charity Organization", ids, is_giveaway=True)
|
2021-02-03 18:54:42 +01:00
|
|
|
|
2021-07-21 15:08:25 +02:00
|
|
|
@action(
|
|
|
|
"journalist_upgrade",
|
|
|
|
"Journalist upgrade",
|
|
|
|
"Are you sure you want to upgrade selected users using the Journalist program?",
|
|
|
|
)
|
|
|
|
def action_journalist_upgrade(self, ids):
|
|
|
|
manual_upgrade("Journalist", ids, is_giveaway=True)
|
|
|
|
|
2021-01-11 20:24:33 +01:00
|
|
|
@action(
|
|
|
|
"cash_upgrade",
|
|
|
|
"Cash upgrade",
|
|
|
|
"Are you sure you want to cash-upgrade selected users?",
|
|
|
|
)
|
|
|
|
def action_cash_upgrade(self, ids):
|
2021-03-26 12:14:33 +01:00
|
|
|
manual_upgrade("Cash", ids, is_giveaway=False)
|
2021-01-11 20:24:33 +01:00
|
|
|
|
|
|
|
@action(
|
2021-02-15 16:40:19 +01:00
|
|
|
"crypto_upgrade",
|
|
|
|
"Crypto upgrade",
|
|
|
|
"Are you sure you want to crypto-upgrade selected users?",
|
2021-01-11 20:24:33 +01:00
|
|
|
)
|
|
|
|
def action_monero_upgrade(self, ids):
|
2021-03-26 12:14:33 +01:00
|
|
|
manual_upgrade("Crypto", ids, is_giveaway=False)
|
2021-02-15 16:39:23 +01:00
|
|
|
|
2022-03-02 19:05:17 +01:00
|
|
|
@action(
|
|
|
|
"adhoc_upgrade",
|
|
|
|
"Adhoc upgrade - for exceptional case",
|
|
|
|
"Are you sure you want to crypto-upgrade selected users?",
|
|
|
|
)
|
|
|
|
def action_adhoc_upgrade(self, ids):
|
|
|
|
manual_upgrade("Adhoc", ids, is_giveaway=False)
|
|
|
|
|
2021-02-25 10:09:02 +01:00
|
|
|
@action(
|
|
|
|
"extend_trial_1w",
|
|
|
|
"Extend trial for 1 week more",
|
|
|
|
"Extend trial for 1 week more?",
|
|
|
|
)
|
|
|
|
def extend_trial_1w(self, ids):
|
2021-10-12 14:36:47 +02:00
|
|
|
for user in User.filter(User.id.in_(ids)):
|
2021-02-25 10:09:02 +01:00
|
|
|
if user.trial_end and user.trial_end > arrow.now():
|
|
|
|
user.trial_end = user.trial_end.shift(weeks=1)
|
|
|
|
else:
|
|
|
|
user.trial_end = arrow.now().shift(weeks=1)
|
|
|
|
|
|
|
|
flash(f"Extend trial for {user} to {user.trial_end}", "success")
|
2022-03-14 15:07:51 +01:00
|
|
|
AdminAuditLog.extend_trial(
|
|
|
|
current_user.id, user.id, user.trial_end, "1 week"
|
|
|
|
)
|
2021-02-25 10:09:02 +01:00
|
|
|
|
2021-10-12 14:36:47 +02:00
|
|
|
Session.commit()
|
2021-02-25 10:09:02 +01:00
|
|
|
|
2024-02-05 13:47:39 +01:00
|
|
|
@action(
|
|
|
|
"remove trial",
|
|
|
|
"Stop trial period",
|
|
|
|
"Remove trial for this user?",
|
|
|
|
)
|
|
|
|
def stop_trial(self, ids):
|
|
|
|
for user in User.filter(User.id.in_(ids)):
|
|
|
|
user.trial_end = None
|
|
|
|
|
|
|
|
flash(f"Stopped trial for {user}", "success")
|
|
|
|
AdminAuditLog.stop_trial(current_user.id, user.id)
|
|
|
|
|
|
|
|
Session.commit()
|
|
|
|
|
2021-07-22 09:09:13 +02:00
|
|
|
@action(
|
2021-11-22 11:31:49 +01:00
|
|
|
"disable_otp_fido",
|
|
|
|
"Disable OTP & FIDO",
|
|
|
|
"Disable OTP & FIDO?",
|
2021-07-22 09:09:13 +02:00
|
|
|
)
|
2021-11-22 11:31:49 +01:00
|
|
|
def disable_otp_fido(self, ids):
|
2021-10-12 14:36:47 +02:00
|
|
|
for user in User.filter(User.id.in_(ids)):
|
2022-03-10 16:13:31 +01:00
|
|
|
user_had_otp = user.enable_otp
|
2021-07-22 09:09:13 +02:00
|
|
|
if user.enable_otp:
|
|
|
|
user.enable_otp = False
|
|
|
|
flash(f"Disable OTP for {user}", "info")
|
|
|
|
|
2022-03-10 16:13:31 +01:00
|
|
|
user_had_fido = user.fido_uuid is not None
|
2021-11-22 11:31:49 +01:00
|
|
|
if user.fido_uuid:
|
2021-11-22 15:58:11 +01:00
|
|
|
Fido.filter_by(uuid=user.fido_uuid).delete()
|
2021-11-22 11:31:49 +01:00
|
|
|
user.fido_uuid = None
|
|
|
|
flash(f"Disable FIDO for {user}", "info")
|
2022-03-10 16:13:31 +01:00
|
|
|
AdminAuditLog.disable_otp_fido(
|
|
|
|
current_user.id, user.id, user_had_otp, user_had_fido
|
|
|
|
)
|
2021-11-22 11:31:49 +01:00
|
|
|
|
2021-10-12 14:36:47 +02:00
|
|
|
Session.commit()
|
2021-07-22 09:09:13 +02:00
|
|
|
|
2022-08-04 09:20:07 +02:00
|
|
|
@action(
|
|
|
|
"stop_paddle_sub",
|
|
|
|
"Stop user Paddle subscription",
|
|
|
|
"This will stop the current user Paddle subscription so if user doesn't have Proton sub, they will lose all SL benefits immediately",
|
|
|
|
)
|
|
|
|
def stop_paddle_sub(self, ids):
|
|
|
|
for user in User.filter(User.id.in_(ids)):
|
|
|
|
sub: Subscription = user.get_paddle_subscription()
|
|
|
|
if not sub:
|
|
|
|
flash(f"No Paddle sub for {user}", "warning")
|
|
|
|
continue
|
|
|
|
|
|
|
|
flash(f"{user} sub will end now, instead of {sub.next_bill_date}", "info")
|
|
|
|
sub.next_bill_date = (
|
|
|
|
arrow.now().shift(days=-PADDLE_SUBSCRIPTION_GRACE_DAYS).date()
|
|
|
|
)
|
|
|
|
|
|
|
|
Session.commit()
|
|
|
|
|
2023-09-10 22:11:50 +02:00
|
|
|
@action(
|
|
|
|
"clear_delete_on",
|
|
|
|
"Remove scheduled deletion of user",
|
|
|
|
"This will remove the scheduled deletion for this users",
|
|
|
|
)
|
|
|
|
def clean_delete_on(self, ids):
|
|
|
|
for user in User.filter(User.id.in_(ids)):
|
|
|
|
user.delete_on = None
|
|
|
|
|
|
|
|
Session.commit()
|
|
|
|
|
2022-02-28 16:40:07 +01:00
|
|
|
# @action(
|
|
|
|
# "login_as",
|
|
|
|
# "Login as this user",
|
|
|
|
# "Login as this user?",
|
|
|
|
# )
|
|
|
|
# def login_as(self, ids):
|
|
|
|
# if len(ids) != 1:
|
|
|
|
# flash("only 1 user can be selected", "error")
|
|
|
|
# return
|
|
|
|
#
|
|
|
|
# for user in User.filter(User.id.in_(ids)):
|
2022-03-10 18:10:13 +01:00
|
|
|
# AdminAuditLog.logged_as_user(current_user.id, user.id)
|
2022-02-28 16:40:07 +01:00
|
|
|
# login_user(user)
|
|
|
|
# flash(f"Login as user {user}", "success")
|
|
|
|
# return redirect("/")
|
2021-08-15 22:14:52 +02:00
|
|
|
|
|
|
|
|
2021-03-26 12:14:33 +01:00
|
|
|
def manual_upgrade(way: str, ids: [int], is_giveaway: bool):
|
2021-10-12 14:36:47 +02:00
|
|
|
for user in User.filter(User.id.in_(ids)).all():
|
2021-11-29 16:17:24 +01:00
|
|
|
if user.lifetime:
|
|
|
|
flash(f"user {user} already has a lifetime license", "warning")
|
|
|
|
continue
|
|
|
|
|
2022-06-20 14:34:20 +02:00
|
|
|
sub: Subscription = user.get_paddle_subscription()
|
2021-11-29 16:17:24 +01:00
|
|
|
if sub and not sub.cancelled:
|
|
|
|
flash(
|
|
|
|
f"user {user} already has a Paddle license, they have to cancel it first",
|
|
|
|
"warning",
|
|
|
|
)
|
|
|
|
continue
|
|
|
|
|
|
|
|
apple_sub: AppleSubscription = AppleSubscription.get_by(user_id=user.id)
|
|
|
|
if apple_sub and apple_sub.is_valid():
|
|
|
|
flash(
|
|
|
|
f"user {user} already has a Apple subscription, they have to cancel it first",
|
|
|
|
"warning",
|
|
|
|
)
|
|
|
|
continue
|
|
|
|
|
2022-03-10 16:13:31 +01:00
|
|
|
AdminAuditLog.create_manual_upgrade(current_user.id, way, user.id, is_giveaway)
|
2021-03-26 12:14:33 +01:00
|
|
|
manual_sub: ManualSubscription = ManualSubscription.get_by(user_id=user.id)
|
|
|
|
if manual_sub:
|
|
|
|
# renew existing subscription
|
|
|
|
if manual_sub.end_at > arrow.now():
|
|
|
|
manual_sub.end_at = manual_sub.end_at.shift(years=1)
|
|
|
|
else:
|
|
|
|
manual_sub.end_at = arrow.now().shift(years=1, days=1)
|
|
|
|
flash(f"Subscription extended to {manual_sub.end_at.humanize()}", "success")
|
|
|
|
continue
|
|
|
|
|
2021-02-15 16:39:23 +01:00
|
|
|
ManualSubscription.create(
|
|
|
|
user_id=user.id,
|
|
|
|
end_at=arrow.now().shift(years=1, days=1),
|
|
|
|
comment=way,
|
|
|
|
is_giveaway=is_giveaway,
|
|
|
|
)
|
2021-01-11 20:24:33 +01:00
|
|
|
|
2021-03-26 12:14:33 +01:00
|
|
|
flash(f"New {way} manual subscription for {user} is created", "success")
|
2022-03-10 16:13:31 +01:00
|
|
|
Session.commit()
|
2021-01-11 20:24:33 +01:00
|
|
|
|
2021-01-08 18:53:01 +01:00
|
|
|
|
|
|
|
class EmailLogAdmin(SLModelView):
|
2021-01-11 12:04:37 +01:00
|
|
|
column_searchable_list = ["id"]
|
2021-03-30 19:08:32 +02:00
|
|
|
column_filters = ["id", "user.email", "mailbox.email", "contact.website_email"]
|
2021-01-08 18:53:01 +01:00
|
|
|
|
|
|
|
can_edit = False
|
|
|
|
can_create = False
|
|
|
|
|
|
|
|
|
|
|
|
class AliasAdmin(SLModelView):
|
|
|
|
column_searchable_list = ["id", "user.email", "email", "mailbox.email"]
|
2021-04-12 10:07:17 +02:00
|
|
|
column_filters = ["id", "user.email", "email", "mailbox.email"]
|
2021-01-12 18:14:35 +01:00
|
|
|
|
2022-07-04 11:05:13 +02:00
|
|
|
@action(
|
|
|
|
"disable_email_spoofing_check",
|
|
|
|
"Disable email spoofing protection",
|
|
|
|
"Disable email spoofing protection?",
|
|
|
|
)
|
|
|
|
def disable_email_spoofing_check_for(self, ids):
|
|
|
|
for alias in Alias.filter(Alias.id.in_(ids)):
|
|
|
|
if alias.disable_email_spoofing_check:
|
|
|
|
flash(
|
|
|
|
f"Email spoofing protection is already disabled on {alias.email}",
|
|
|
|
"warning",
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
alias.disable_email_spoofing_check = True
|
|
|
|
flash(
|
|
|
|
f"Email spoofing protection is disabled on {alias.email}", "success"
|
|
|
|
)
|
|
|
|
|
|
|
|
Session.commit()
|
|
|
|
|
2021-01-12 18:14:35 +01:00
|
|
|
|
|
|
|
class MailboxAdmin(SLModelView):
|
|
|
|
column_searchable_list = ["id", "user.email", "email"]
|
2021-04-12 10:07:17 +02:00
|
|
|
column_filters = ["id", "user.email", "email"]
|
2021-01-27 10:08:49 +01:00
|
|
|
|
|
|
|
|
2022-02-28 16:40:07 +01:00
|
|
|
# class LifetimeCouponAdmin(SLModelView):
|
|
|
|
# can_edit = True
|
|
|
|
# can_create = True
|
2021-02-24 09:48:06 +01:00
|
|
|
|
|
|
|
|
2021-07-13 08:55:04 +02:00
|
|
|
class CouponAdmin(SLModelView):
|
2022-03-02 19:04:30 +01:00
|
|
|
can_edit = False
|
2021-07-13 08:55:04 +02:00
|
|
|
can_create = True
|
|
|
|
|
|
|
|
|
2021-02-24 09:48:06 +01:00
|
|
|
class ManualSubscriptionAdmin(SLModelView):
|
2022-03-14 16:47:30 +01:00
|
|
|
can_edit = True
|
2021-02-24 09:49:08 +01:00
|
|
|
column_searchable_list = ["id", "user.email"]
|
2021-02-24 09:48:06 +01:00
|
|
|
|
|
|
|
@action(
|
|
|
|
"extend_1y",
|
|
|
|
"Extend for 1 year",
|
|
|
|
"Extend 1 year more?",
|
|
|
|
)
|
|
|
|
def extend_1y(self, ids):
|
2021-10-12 14:36:47 +02:00
|
|
|
for ms in ManualSubscription.filter(ManualSubscription.id.in_(ids)):
|
2021-02-24 09:48:06 +01:00
|
|
|
ms.end_at = ms.end_at.shift(years=1)
|
2022-03-02 19:04:45 +01:00
|
|
|
flash(f"Extend subscription for 1 year for {ms.user}", "success")
|
2022-03-14 15:07:51 +01:00
|
|
|
AdminAuditLog.extend_subscription(
|
|
|
|
current_user.id, ms.user.id, ms.end_at, "1 year"
|
|
|
|
)
|
2022-03-02 19:04:45 +01:00
|
|
|
|
|
|
|
Session.commit()
|
|
|
|
|
|
|
|
@action(
|
|
|
|
"extend_1m",
|
|
|
|
"Extend for 1 month",
|
|
|
|
"Extend 1 month more?",
|
|
|
|
)
|
|
|
|
def extend_1m(self, ids):
|
|
|
|
for ms in ManualSubscription.filter(ManualSubscription.id.in_(ids)):
|
|
|
|
ms.end_at = ms.end_at.shift(months=1)
|
|
|
|
flash(f"Extend subscription for 1 month for {ms.user}", "success")
|
2022-03-14 15:07:51 +01:00
|
|
|
AdminAuditLog.extend_subscription(
|
|
|
|
current_user.id, ms.user.id, ms.end_at, "1 month"
|
|
|
|
)
|
2021-02-24 09:48:06 +01:00
|
|
|
|
2021-10-12 14:36:47 +02:00
|
|
|
Session.commit()
|
2021-04-06 19:46:38 +02:00
|
|
|
|
|
|
|
|
2022-02-28 16:40:07 +01:00
|
|
|
# class ClientAdmin(SLModelView):
|
|
|
|
# column_searchable_list = ["name", "description", "user.email"]
|
|
|
|
# column_exclude_list = ["oauth_client_secret", "home_url"]
|
|
|
|
# can_edit = True
|
2021-05-10 15:51:39 +02:00
|
|
|
|
|
|
|
|
2021-08-24 19:43:32 +02:00
|
|
|
class CustomDomainAdmin(SLModelView):
|
|
|
|
column_searchable_list = ["domain", "user.email", "user.id"]
|
|
|
|
column_exclude_list = ["ownership_txt_token"]
|
|
|
|
can_edit = False
|
|
|
|
|
|
|
|
|
2021-05-10 15:51:39 +02:00
|
|
|
class ReferralAdmin(SLModelView):
|
|
|
|
column_searchable_list = ["id", "user.email", "code", "name"]
|
|
|
|
column_filters = ["id", "user.email", "code", "name"]
|
|
|
|
|
|
|
|
def scaffold_list_columns(self):
|
|
|
|
ret = super().scaffold_list_columns()
|
|
|
|
ret.insert(0, "nb_user")
|
|
|
|
ret.insert(0, "nb_paid_user")
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2022-03-10 18:13:33 +01:00
|
|
|
# class PayoutAdmin(SLModelView):
|
|
|
|
# column_searchable_list = ["id", "user.email"]
|
|
|
|
# column_filters = ["id", "user.email"]
|
|
|
|
# can_edit = True
|
|
|
|
# can_create = True
|
|
|
|
# can_delete = True
|
2022-03-10 17:32:35 +01:00
|
|
|
|
|
|
|
|
2022-03-14 15:28:53 +01:00
|
|
|
def _admin_action_formatter(view, context, model, name):
|
|
|
|
action_name = AuditLogActionEnum.get_name(model.action)
|
|
|
|
return "{} ({})".format(action_name, model.action)
|
|
|
|
|
|
|
|
|
2022-03-14 15:40:50 +01:00
|
|
|
def _admin_created_at_formatter(view, context, model, name):
|
|
|
|
return model.created_at.format()
|
|
|
|
|
|
|
|
|
2022-03-10 17:32:35 +01:00
|
|
|
class AdminAuditLogAdmin(SLModelView):
|
2022-03-14 15:40:50 +01:00
|
|
|
column_searchable_list = ["admin.id", "admin.email", "model_id", "created_at"]
|
|
|
|
column_filters = ["admin.id", "admin.email", "model_id", "created_at"]
|
2022-03-14 15:28:53 +01:00
|
|
|
column_exclude_list = ["id"]
|
2022-03-10 17:49:30 +01:00
|
|
|
column_hide_backrefs = False
|
2022-03-10 17:32:35 +01:00
|
|
|
can_edit = False
|
|
|
|
can_create = False
|
|
|
|
can_delete = False
|
2022-03-14 15:28:53 +01:00
|
|
|
|
2022-03-14 15:40:50 +01:00
|
|
|
column_formatters = {
|
|
|
|
"action": _admin_action_formatter,
|
|
|
|
"created_at": _admin_created_at_formatter,
|
|
|
|
}
|
2022-04-14 18:46:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
def _transactionalcomplaint_state_formatter(view, context, model, name):
|
2022-04-25 14:40:42 +02:00
|
|
|
return "{} ({})".format(ProviderComplaintState(model.state).name, model.state)
|
2022-04-14 18:46:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
def _transactionalcomplaint_phase_formatter(view, context, model, name):
|
|
|
|
return Phase(model.phase).name
|
|
|
|
|
|
|
|
|
|
|
|
def _transactionalcomplaint_refused_email_id_formatter(view, context, model, name):
|
|
|
|
markupstring = "<a href='{}'>{}</a>".format(
|
|
|
|
url_for(".download_eml", id=model.id), model.refused_email.full_report_path
|
|
|
|
)
|
|
|
|
return Markup(markupstring)
|
|
|
|
|
|
|
|
|
2022-04-25 14:40:42 +02:00
|
|
|
class ProviderComplaintAdmin(SLModelView):
|
2022-04-14 18:46:11 +02:00
|
|
|
column_searchable_list = ["id", "user.id", "created_at"]
|
|
|
|
column_filters = ["user.id", "state"]
|
|
|
|
column_hide_backrefs = False
|
|
|
|
can_edit = False
|
|
|
|
can_create = False
|
|
|
|
can_delete = False
|
|
|
|
|
|
|
|
column_formatters = {
|
|
|
|
"created_at": _admin_created_at_formatter,
|
|
|
|
"updated_at": _admin_created_at_formatter,
|
|
|
|
"state": _transactionalcomplaint_state_formatter,
|
|
|
|
"phase": _transactionalcomplaint_phase_formatter,
|
|
|
|
"refused_email": _transactionalcomplaint_refused_email_id_formatter,
|
|
|
|
}
|
|
|
|
|
|
|
|
column_extra_row_actions = [ # Add a new action button
|
|
|
|
EndpointLinkRowAction("fa fa-check-square", ".mark_ok"),
|
|
|
|
]
|
|
|
|
|
2022-04-25 14:40:42 +02:00
|
|
|
def _get_complaint(self) -> Optional[ProviderComplaint]:
|
2022-04-14 18:46:11 +02:00
|
|
|
complain_id = request.args.get("id")
|
|
|
|
if complain_id is None:
|
|
|
|
flash("Missing id", "error")
|
|
|
|
return None
|
2022-04-25 14:40:42 +02:00
|
|
|
complaint = ProviderComplaint.get_by(id=complain_id)
|
2022-04-14 18:46:11 +02:00
|
|
|
if not complaint:
|
|
|
|
flash("Could not find complaint", "error")
|
|
|
|
return None
|
|
|
|
return complaint
|
|
|
|
|
|
|
|
@expose("/mark_ok", methods=["GET"])
|
|
|
|
def mark_ok(self):
|
|
|
|
complaint = self._get_complaint()
|
|
|
|
if not complaint:
|
|
|
|
return redirect("/admin/transactionalcomplaint/")
|
2022-04-25 14:40:42 +02:00
|
|
|
complaint.state = ProviderComplaintState.reviewed.value
|
2022-04-14 18:46:11 +02:00
|
|
|
Session.commit()
|
|
|
|
return redirect("/admin/transactionalcomplaint/")
|
|
|
|
|
|
|
|
@expose("/download_eml", methods=["GET"])
|
|
|
|
def download_eml(self):
|
|
|
|
complaint = self._get_complaint()
|
|
|
|
if not complaint:
|
|
|
|
return redirect("/admin/transactionalcomplaint/")
|
|
|
|
eml_path = complaint.refused_email.full_report_path
|
|
|
|
eml_data = s3.download_email(eml_path)
|
2022-04-25 14:40:42 +02:00
|
|
|
AdminAuditLog.downloaded_provider_complaint(current_user.id, complaint.id)
|
2022-04-14 18:46:11 +02:00
|
|
|
Session.commit()
|
|
|
|
return Response(
|
|
|
|
eml_data,
|
|
|
|
mimetype="message/rfc822",
|
|
|
|
headers={
|
|
|
|
"Content-Disposition": "attachment;filename={}".format(
|
|
|
|
complaint.refused_email.path
|
|
|
|
)
|
|
|
|
},
|
|
|
|
)
|
2022-07-22 11:24:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
def _newsletter_plain_text_formatter(view, context, model: Newsletter, name):
|
|
|
|
# to display newsletter plain_text with linebreaks in the list view
|
|
|
|
return Markup(model.plain_text.replace("\n", "<br>"))
|
|
|
|
|
|
|
|
|
|
|
|
def _newsletter_html_formatter(view, context, model: Newsletter, name):
|
|
|
|
# to display newsletter html with linebreaks in the list view
|
|
|
|
return Markup(model.html.replace("\n", "<br>"))
|
|
|
|
|
|
|
|
|
|
|
|
class NewsletterAdmin(SLModelView):
|
|
|
|
list_template = "admin/model/newsletter-list.html"
|
|
|
|
edit_template = "admin/model/newsletter-edit.html"
|
|
|
|
edit_modal = False
|
|
|
|
|
|
|
|
can_edit = True
|
|
|
|
can_create = True
|
|
|
|
|
|
|
|
column_formatters = {
|
|
|
|
"plain_text": _newsletter_plain_text_formatter,
|
|
|
|
"html": _newsletter_html_formatter,
|
|
|
|
}
|
|
|
|
|
|
|
|
@action(
|
|
|
|
"send_newsletter_to_user",
|
|
|
|
"Send this newsletter to myself or the specified userID",
|
|
|
|
)
|
|
|
|
def send_newsletter_to_user(self, newsletter_ids):
|
|
|
|
user_id = request.form["user_id"]
|
|
|
|
if user_id:
|
|
|
|
user = User.get(user_id)
|
|
|
|
if not user:
|
|
|
|
flash(f"No such user with ID {user_id}", "error")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
flash("use the current user", "info")
|
|
|
|
user = current_user
|
|
|
|
|
|
|
|
for newsletter_id in newsletter_ids:
|
|
|
|
newsletter = Newsletter.get(newsletter_id)
|
|
|
|
sent, error_msg = send_newsletter_to_user(newsletter, user)
|
|
|
|
if sent:
|
|
|
|
flash(f"{newsletter} sent to {user}", "success")
|
|
|
|
else:
|
|
|
|
flash(error_msg, "error")
|
|
|
|
|
|
|
|
@action(
|
|
|
|
"send_newsletter_to_address",
|
|
|
|
"Send this newsletter to a specific address",
|
|
|
|
)
|
|
|
|
def send_newsletter_to_address(self, newsletter_ids):
|
|
|
|
to_address = request.form["to_address"]
|
|
|
|
if not to_address:
|
|
|
|
flash("to_address missing", "error")
|
|
|
|
return
|
|
|
|
|
|
|
|
for newsletter_id in newsletter_ids:
|
|
|
|
newsletter = Newsletter.get(newsletter_id)
|
|
|
|
# use the current_user for rendering email
|
|
|
|
sent, error_msg = send_newsletter_to_address(
|
|
|
|
newsletter, current_user, to_address
|
|
|
|
)
|
|
|
|
if sent:
|
|
|
|
flash(
|
|
|
|
f"{newsletter} sent to {to_address} with {current_user} context",
|
|
|
|
"success",
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
flash(error_msg, "error")
|
|
|
|
|
2023-11-07 14:16:03 +01:00
|
|
|
@action(
|
|
|
|
"clone_newsletter",
|
|
|
|
"Clone this newsletter",
|
|
|
|
)
|
|
|
|
def clone_newsletter(self, newsletter_ids):
|
|
|
|
if len(newsletter_ids) != 1:
|
|
|
|
flash("you can only select 1 newsletter", "error")
|
|
|
|
return
|
|
|
|
|
|
|
|
newsletter_id = newsletter_ids[0]
|
|
|
|
newsletter: Newsletter = Newsletter.get(newsletter_id)
|
|
|
|
new_newsletter = Newsletter.create(
|
|
|
|
subject=newsletter.subject,
|
|
|
|
html=newsletter.html,
|
|
|
|
plain_text=newsletter.plain_text,
|
|
|
|
commit=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
flash(f"Newsletter {new_newsletter.subject} has been cloned", "success")
|
|
|
|
|
2022-07-22 11:24:53 +02:00
|
|
|
|
|
|
|
class NewsletterUserAdmin(SLModelView):
|
|
|
|
column_searchable_list = ["id"]
|
|
|
|
column_filters = ["id", "user.email", "newsletter.subject"]
|
|
|
|
column_exclude_list = ["created_at", "updated_at", "id"]
|
|
|
|
|
|
|
|
can_edit = False
|
|
|
|
can_create = False
|
2022-10-15 19:10:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
class DailyMetricAdmin(SLModelView):
|
|
|
|
column_exclude_list = ["created_at", "updated_at", "id"]
|
|
|
|
|
|
|
|
can_export = True
|
|
|
|
|
|
|
|
|
|
|
|
class MetricAdmin(SLModelView):
|
|
|
|
column_exclude_list = ["created_at", "updated_at", "id"]
|
|
|
|
|
|
|
|
can_export = True
|
2023-02-15 10:38:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidMailboxDomainAdmin(SLModelView):
|
|
|
|
can_create = True
|
|
|
|
can_delete = True
|