Exemple #1
0
 def reset(self):
     if not self.ids['cbox'].active and self.ids['pwd'].text != self.ids[
             'rpwd'].text:
         self.highlight_textinput(self.ids['pwd'])
         self.highlight_textinput(self.ids['rpwd'])
         return
     if ':' in self.ids['pwd'].text:
         ErrorPopup(message='Password contains ":"')
         self.highlight_textinput(self.ids['pwd'])
         return
     if self.ids['cbox'].active:
         self.ids['pwd'].text = ''.join(
             choices(list(alphanumeric_chars), k=10))
     username = self.ids['username'].text
     self.selected_acct = self.get_user(username)
     if not self.selected_acct:
         ErrorPopup(username + ' not found')
         return
     self.selected_acct['password'] = tokenize(self.ids['pwd'].text)
     url = urlTo('accounts')
     params = {'superuser': True} if root.sm.is_admin else None
     AsyncRequest(url,
                  method='PATCH',
                  data=self.selected_acct,
                  params=params,
                  on_success=self.success)
Exemple #2
0
 def create(self):
     if not self.ids['cbox'].active and self.ids['pwd'].text != self.ids[
             'rpwd'].text:
         self.highlight_textinput(self.ids['pwd'])
         self.highlight_textinput(self.ids['rpwd'])
         return
     if ':' in self.ids['username'].text:
         ErrorPopup(message='Username contains ":"')
         self.highlight_textinput(self.ids['username'])
         return
     elif ':' in self.ids['pwd'].text:
         ErrorPopup(message='Password contains ":"')
         self.highlight_textinput(self.ids['pwd'])
         return
     if self.ids['cbox'].active:
         self.ids['pwd'].text = ''.join(
             choices(list(alphanumeric_chars), k=10))
     data = {
         'permissions':
         titles_perm[self.ids['title'].text] % self.ids['username'].text
     }
     data[
         'fullname'] = self.ids['fname'].text + ' ' + self.ids['lname'].text
     data['email'] = self.ids['email'].text
     data['username'] = self.ids['username'].text
     data['title'] = self.ids['title'].text
     data['password'] = tokenize(self.ids['pwd'].text)
     url = urlTo('accounts')
     AsyncRequest(url, method='POST', data=data, on_success=self.success)
Exemple #3
0
    def update(self):
        if not self.ids['password'].text:
            ErrorPopup('Password field can\'t be empty')
            return
        if ':' in self.ids['password'].text:
            ErrorPopup('Password contains ":"')
            return

        self.data['password'] = tokenize(self.ids['password'].text)
        self.data['email'] = self.ids['email'].text
        url = urlTo('accounts')
        AsyncRequest(url,
                     data=self.data,
                     method='PATCH',
                     on_success=self.update_success)
Exemple #4
0
 def submit(self):
     if not self.validate_inputs():
         ErrorPopup('Invalid field supplied')
         return
     if self.ids['pwd'].text != self.ids['rpwd'].text:
         self.highlight_textinput(self.ids['pwd'])
         self.highlight_textinput(self.ids['rpwd'])
         return
     if ':' in self.ids['username'].text:
         ErrorPopup(message='Username contains ":"')
         self.highlight_textinput(self.ids['username'])
         return
     if ':' in self.ids['pwd'].text:
         ErrorPopup(message='Password contains ":"')
         self.highlight_textinput(self.ids['pwd'])
         return
     data = {
         'fullname': self.ids['fname'].text + ' ' + self.ids['lname'].text,
         'email': self.ids['email'].text,
         'username': self.ids['username'].text,
         'password': tokenize(self.ids['pwd'].text)
     }
     AuthenticationPopup(data=data).open()
Exemple #5
0
 def confirm(self):
     url = urlTo('handover')
     self.data['old_username'] = self.ids['username'].text
     self.data['old_password'] = tokenize(self.ids['pwd'].text)
     AsyncRequest(url, method='POST', data=self.data, on_success=self.handover_success)