mewlo.mpacks.site_addons.account.msiteaddon_account_manager module

msiteaddon_account_manager.py This file contains helper code for account login and registration tyoe stuff

class mewlo.mpacks.site_addons.account.msiteaddon_account_manager.AccountAddonManager(mewlosite, debugmode)[source]

Bases: mewlo.mpacks.core.manager.manager.MewloManager

This class is used to help processing requests.

calc_verificationurl_passwordreset(verification)[source]

Build url user should visit to verify.

calc_verificationurl_registration_deferred(verification)[source]

Compute the verification url for a verification object for deferred registration. This will require asking the site what the base url should be.

cancel_modify_field_form(request, fieldname)[source]

Cancel a pending verification for field change request.

create_newuser(request, userdict, verifiedfields=[])[source]

Create a new user right away. Send them an email verification link after.

description = 'Account management addon provides user login/registration functions'
finalize_registration_deferred_withverification(request, verification)[source]

They have provided a valid registration code which we matched to a verification entry; now we will let them fill in the final form to create their account. See try_verify_registration_deferred_withcode for more info.

get_user_force_login(request, reasonmessage='You must login first before you can access this page.')[source]

Return the logged in user. But if user is not logged in, reroute/redirect to login page (and then back to current request), and return None.

get_user_force_recentpassword(request, recentminutes, reasonmessage="It's been a while since you logged in so you need to provide your password again before you can continue.")[source]

Return the logged in user. But if user is not logged in, reroute/redirect to login page (and then back to current request), and return None.

handle_modify_field_form(request, user, fieldname, formclass)[source]

Present form where user can modify field.

request_cancel_modify_field(request)[source]

User wants to cancel a pending verification of a changed field request (email, password, etc.). NOTE: Eventually we will have nicer profile pages where they can change fields, this is more of an example to show the process involved when changing a field that needs a verification code sent.

request_login(request)[source]

Present and consume the login form.

request_logout(request)[source]

Present and consume the logour form. Return failure.

request_modify_field(request)[source]

User wants to change a field (email, password, etc.). For some of these we may need to send them a verification before we can actually change it. NOTE: Eventually we will have nicer profile pages where they can change fields, this is more of an example to show the process involved when changing a field that needs a verification code sent.

request_profile(request)[source]

View user profile.

request_register(request)[source]

Controller function: register user.

request_register_deferred_verify(request)[source]

Client visits deferred registration verification page.

request_resend_register_verification(request)[source]

User has asked to be resent their initial registration verification email (for immediate registration method). If we can recognize their session and tie it to a new user verification, we will also offer to let them change their signup email at this point. If we can’t recognize their session, and we still want to let them change their email, we can ask them for their username and password at this point (assuming we gathered it at time of registration).

request_reset_password(request)[source]

User is ready to provide their new (reset) password, and a verification code to prove they are the owner of the account. This is very much like deferred account finalization, where the verification code is put as a hidden field on a form that they will resubmit with their changes.

request_send_reset_password(request)[source]

User needs to reset their password because they can’t remember it (this is different from a password-change once logged in. We just need to ask them for their username and/or email (both if we want to be prevent nuisance filings), and then we can send them a long verification code to reset (change) their password. They will return to this function with a code emailed to them to prove they are the owner of the account, at which point we can accept a new password from them. If we are nice we might recognize them if they are logged in via session, and pre-fill their username+email address.

request_userfield_verify(request)[source]

handle user field verification.

reset_password_withcode(request, verification_code)[source]

Try to complete password reset given a code.

reset_password_withverification(request, verification)[source]

Present them with a form to reset their password.

startup_prep(stageid, eventlist)[source]

This is invoked by site strtup, for each stage specified in startup_stages_needed() above.

try_cancel_modify_field(request, user, fieldname, invalidreason)[source]

Cancel a pending verification for field change request.

try_create_newuser_deferred(request, userdict)[source]

User has submitted a registration attempt with an accompanying validation code. There are a couple of things we need to do here: 1. Re-check the verifcation code make sure it is good 2. Start with pre-specified values in verification, overide using user-specified values that are allowed, IGNORE any changes to a field we used to validate (email) Return tuple (user, errordict, successmessage)

try_find_pending_fieldverification_from_current_session(request, fieldname)[source]

Try to find a pending new registration. Return tupe (User, Verification).

try_find_pending_fieldverification_from_userdict(userdict, fieldname)[source]

Try to find a pending new registration. Return tupe (User, Verification).

try_login(request, userdict)[source]

Try logging in, return a dictionary of errors or REDIRECT if no error. Return error dictionary.

try_login_and_return(request, reasonmessage)[source]

Present and consume the login form – on success don’t send them anywhere. return True if they are logged in and we can present whatever view we want afterwards. return False if not and we presented the login form.

try_logout(request, flag_clearsession)[source]

Just log the user out, and redirect them somewhere. Return failure

try_modify_field_with_verification(request, user, fieldname, fieldval)[source]

Modify the field or create a deferred field modification if it needs verification. return tuple (successmessage,failure).

try_precreate_newuser_deferred_justverification(request, userdict)[source]

Create a verification entry for a new user registration. We take a userdict instead of explicit variables for username, email, password, so that we can eventually accomodate whatever initial user properties we have specified at time of registration. return tuple (verification, errordict, successmessage); if there are errors return them and userobject as None

try_providepassword_and_return(request, user, reasonmessage)[source]

Present and consume the password form – on success don’t send them anywhere. return True if they are logged in and we can present whatever view we want afterwards. return False if not and we presented the login form.

try_register(request, userdict, flag_immediate)[source]

Try registering user. On success, WE display success page. Return tupe (errordict, successmessage).

try_resend_field_verification(request, user, verification, fieldname, fieldval)[source]

Resend a new user their pending registration verification email. If a different email address is specified, CHANGE AND SAVE the verification (and user?) email field first. Return None on success, otherwise failure.

try_reset_password(user, password_plaintext)[source]

Change a user’s password. return Failure

try_send_passwordreset(request, user)[source]

Send the user a password reset verification code.

try_validatecode_passwordreset(request, verification_code)[source]

Locate verification, make sure it’s good Return tuple (verification, failure).

try_verify_registration_validatecode(request, verification_code)[source]

Locate verification, check it for different kinds of errors. return tuple (verification, failure).

try_verify_userfield_validatecode(request, verification_code, verification_varname)[source]

Locate verification, check it for different kinds of errors. return tuple (verification, failure).

typestr = 'siteaddon'
verify_registration_deferred_withcode(request, verification_code)[source]

Try to complete their deferred verification given a code.