akvo.rsr.views.account module

Akvo RSR is covered by the GNU Affero General Public License.

See more details in the license.txt file located at the root folder of the Akvo RSR module. For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.

class akvo.rsr.views.account.DisableTwoFactorView(**kwargs)[source]

Bases: DisableView

get_context_data(**kwargs)[source]

Insert the form into the context dict.

success_url = '/my-rsr/my-details/'
class akvo.rsr.views.account.SetupTwoFactorView(**kwargs)[source]

Bases: SetupView

done(form_list, **kwargs)[source]

Finish the wizard. Save all forms and redirect.

generate_backup_tokens()[source]
get_context_data(form, **kwargs)[source]

Returns the template context for a step. You can overwrite this method to add more data for all or some steps. This method returns a dictionary containing the rendered form step. Available template context variables are:

  • all extra data stored in the storage backend

  • wizard - a dictionary representation of the wizard instance

Example:

class MyWizard(WizardView):
    def get_context_data(self, form, **kwargs):
        context = super().get_context_data(form=form, **kwargs)
        if self.steps.current == 'my_step_name':
            context.update({'another_var': True})
        return context
get_static_device()[source]
get_success_url()[source]
number_of_tokens = 10
success_url = 'two_factor:backup_tokens'
class akvo.rsr.views.account.SignInView(**kwargs)[source]

Bases: LoginView

PASSWORD_STEP = 'password'
condition_dict = {'backup': <function LoginView.has_backup_step>, 'password': <function SignInView.has_password_step>, 'token': <function LoginView.has_token_step>}
done(form_list, **kwargs)[source]

Login the user and redirect to the desired page.

form_list = (('auth', <class 'django.contrib.auth.forms.AuthenticationForm'>), ('token', <class 'two_factor.forms.AuthenticationTokenForm'>), ('backup', <class 'two_factor.forms.BackupTokenForm'>), ('password', <class 'django.contrib.auth.forms.PasswordChangeForm'>))
has_password_step()[source]
class akvo.rsr.views.account.TwoFactorBackupTokensView(**kwargs)[source]

Bases: RedirectURLMixin, BackupTokensView

form_valid(form)[source]

Delete existing backup codes and generate new ones.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

akvo.rsr.views.account.activate(request, activation_key, extra_context=None)[source]

Activate resouce.

Activate a User’s account, if their key is valid and hasn’t expired. Any values passed in the keyword argument “extra_context” (which must be a dictionary) will be added to the context. Any values in “extra_context” which are callable will be called prior to being added to the context.

akvo.rsr.views.account.api_key(request)[source]

On successful user credentials returns an auth token for API usage.

Since RSR changed in v3 to allow users without an organisation we need to introduce a way to make old Up apps work as before but new ones support users without any connected organisations.

akvo.rsr.views.account.api_key_json_response(user, orgs)[source]

Build the JSON response. This is used by the Up app - so make sure they match on change.

akvo.rsr.views.account.api_key_xml_response(user, orgs)[source]

Build the XML response.

This is used by the Up app - so make sure they match on change.

akvo.rsr.views.account.get_csrf_token(request)[source]
akvo.rsr.views.account.get_enforce_2fa(user)[source]
akvo.rsr.views.account.invite_activate(request, inviting_pk, user_pk, employment_pk, token_date, token)[source]

Activate a user that has been invited to use RSR.

Parameters:
  • request – the request

  • inviting_pk – the invitee user’s primary key

  • user_pk – the invited user’s primary key

  • employment_pk – the employment’s primary key

  • token_date – the first part of the token

  • token – the second part of the token

akvo.rsr.views.account.json_login(request)[source]
akvo.rsr.views.account.json_register(request)[source]
akvo.rsr.views.account.json_reset_password(request)[source]
akvo.rsr.views.account.register(request)[source]

Register form.

akvo.rsr.views.account.sign_in(request)[source]

Sign in.

POST have two variants with username & email:
  • username > normal sign in

  • email > password reset workflow

akvo.rsr.views.account.sign_out(request)[source]

Log out resouce.

akvo.rsr.views.account.totp_qrcode(request)[source]