Exemple #1
0
    def  updatePassword(self):
        # This subroutine will update the password for the user

        user = h.user() # gets the users object

        # getsthe old, new, and the retyped new passowrd
        new_pwd = request.params['pwd_new']
        old_pwd = request.params['pwd_old']
        new_pwd_re = request.params['pwd_new_re']

        # test to see if they've entered the correct old passwrd
        if (new_pwd =='') and (old_pwd =='') and (new_pwd_re ==''):
        # If nothing was entered, user just pressed the button
            pass
        elif user.validate_password(old_pwd):

            # test to see if they've netered the new password in correctly
            if new_pwd == new_pwd_re:
            # update the user with the new password
                user.set_password(new_pwd)
                Session.commit()
                h.flash_ok(u"Your password has changed.")
            else:
             h.flash_alert(u"Password change failed.")
        else:
            h.flash_alert(u"Password change failed.")

        c.user = user
        c.user_level = Session.query(UserLevels).filter(UserLevels.ulid==c.user.level).first()
        return render("/home.mako")
Exemple #2
0
    def index(self):
    # This function is called after the  login has been visited
        c.user = h.user()

        if c.user is None:

            h.flash_alert(u"Login Failed. Please try again.")
            return render('/account/login.mako')

        c.user_level = Session.query(UserLevels).filter(UserLevels.ulid==c.user.level).first()
        return render('home.mako')
Exemple #3
0
    def index(self):
        # The default page for the client tab

        c.user = h.user()
        c.user_level = Session.query(UserLevels).filter(UserLevels.ulid==c.user.level).first()

        # Debtors should not have access to this menu
        if (c.user_level.name == 'Debtor'):
            # Alert the user
            h.flash_alert(u"Debtors do not have access to this menu.")

            # Redirect the user to the
            return render('/')
        
        return render('/client/client.mako')
Exemple #4
0
 def activation(self):
     success = False
     
     username = request.params.get('u')
     if username:
         user = Session.query(User).filter_by(username=username).first()
         if user is not None:
             key = request.params.get('key')
             if key and user.activation:
                 if user.activation.key == key:
                     Session.delete(user.activation)
                     user.activated = True
                     Session.commit()
                     success = True
     
     if success:
         h.flash_ok(u"Your account has been activated.  You may now login with username '%s'" %(users.username))
     else:
         h.flash_alert(u"Activation failed. The specified username or key may not be correct.")
     
     redirect("/account/login")
Exemple #5
0
    def updateUserInfo(self):
            # This subroutine will update the users inforamtion

            error =False
            changed =False

            # get the parameters from the form
            new_name = request.params['name']
            new_username = request.params['username']
            new_userlevel = request.params['userlevel']
            new_email = request.params['email']
            new_address = request.params['address']
            new_city = request.params['city']
            new_state = request.params['state']
            new_zip = request.params['zip']

            c.user =h.user() # get the user object
            usernames = Session.query(Users.username)
            emails = Session.query(Users.email)
            g =Geocoder()
        
            # gets the users level
            c.user_level = Session.query(UserLevels).filter(UserLevels.ulid==c.user.level).first()

            if c.user_level.name != new_userlevel:
                # test to see if the users level has been changed, ERROR if so
                error = True
                h.flash_alert(u"User Level change is prohibited.")

            if (c.user.username != new_username) and (error ==False):
                # Test to see if the user name has changed

                if not new_username in usernames:
                # test to see if the username is unique
                    c.user.username = new_username
                    Session.commit()
                    changed =True

                else:
                # The use name is not unique
                    h.flash_alert(u"Username already taken.")

             # Test to see if the address changed
            if (new_address != '') and (new_city !='') and (new_state != '') and (new_zip != '') and (error ==False) and (g.geocode(new_address+ ' ' + new_city +', '+ new_state+' '+ new_zip).valid_address !=False):
                 # There are not any empty address fields and the address is valid
                 # Check to see if there are any changes

                 if (c.user.address != new_address):
                     # address change
                     c.user.address =new_address
                     Session.commit()
                     if changed != True: changed =True

                 if (c.user.city != new_city):
                     # new city
                     c.user.city =new_city
                     Session.commit()
                     if changed != True: changed =True

                 if (c.user.state != new_state):
                     # new state
                     c.user.state =new_state
                     Session.commit()
                     if changed != True: changed =True

                 if (c.user.zip != new_zip):
                     # new zip code
                     c.user.zip =new_zip
                     Session.commit()
                     if changed != True: changed =True

            elif (c.user.address == new_address) and (c.user.state == new_state) and (c.user.city == new_city) and (c.user.zp ==new_zip):
                # If everything in the form address wise has not been changed then there is nothing that needs to be done
                pass

            else:
                # The address was bad
                error = True
                h.flash_alert(u"Improper Address.")

            if changed ==True and error ==False:
                h.flash_ok(u"Your user account is updated.")
                
            return render('/home.mako')