コード例 #1
0
def reset_pw(request):
    dbsession = request.db
    try:
        login = request.params['username']
        email = request.params['email']

        if not login or not email:
            raise MissingQueryParameterError(
                'Missing information for reset password process.')

        if 'form.submitted' in request.params:
            user = Users.by_username(login, dbsession)
            if user and user.email == email:
                # register ticket in database
                newTicket = Fehlermeldung(fehlerbeschreibung="Passwort reset",
                                          timestamp=getTimestampAsPGStr(),
                                          referenz="users",
                                          nutzerid=user.login,
                                          objektid=user.id)
                dbsession.add(newTicket)

                # reset password
                newPassword = generateRandomString(10)
                user._set_password(newPassword)

                # send new password
                reset_msg = password_reset_msg.format(
                    user=str(user.login), new_password=str(newPassword))
                response = sendMailCommandLine(
                    user.email, 'Your password has been changed!', reset_msg)
                if not response:
                    raise InternalAuthentificationError(
                        'Internal server error while trying to send you your new password. Please try again or contact the page administrator.'
                    )

                # create response
                target_url = request.route_url('auth',
                                               action='page_reset_success')
                transaction.commit()
                return HTTPFound(location=target_url)
            else:
                raise InternalAuthentificationError(
                    'Internal server error while trying to change password. Please try again or contact the page administrator.'
                )

        else:
            raise MissingQueryParameterError('Missing form validation.')

    except MissingQueryParameterError, InternalAuthentificationError:
        raise
コード例 #2
0
def getPage_profileMtb(request):
    try:
        messtischblatt_id = None
        if 'id' in request.params:
            messtischblatt_id = request.params['id']
            log.info('Receive get profile mtb page for id %s.' %
                     messtischblatt_id)

        messtischblatt = Messtischblatt.by_id(messtischblatt_id, request.db)

        user_id = authenticated_userid(request)
        if user_id:
            groups = groupfinder(user_id, request)
            if groups and 'g:moderator' in groups or 'g:admin' in groups:
                return {
                    'with_modify': True,
                    'zoomify_prop': messtischblatt.zoomify_properties,
                    'zoomify_width': messtischblatt.zoomify_width,
                    'zoomify_height': messtischblatt.zoomify_height,
                    'key': messtischblatt.dateiname
                }

        return {
            'zoomify_prop': messtischblatt.zoomify_properties,
            'zoomify_width': messtischblatt.zoomify_width,
            'zoomify_height': messtischblatt.zoomify_height,
            'key': messtischblatt.dateiname
        }
    except:
        log.error(
            'Internal server error while trying to get profile page. Please try again or contact the page administrator.'
        )
        raise InternalAuthentificationError(
            'Internal server error while trying to get profile page. Please try again or contact the page administrator.'
        )
コード例 #3
0
def register_new_user(request):

    login = ''
    password = ''
    _ = request.translate
    dbsession = request.db
    try:
        login = request.params['username']
        password = request.params['password']
        email = request.params['email']
        vorname = request.params['vorname'] 
        nachname = request.params['nachname']
        
        if not login or not password or not email or not vorname or not nachname:
            raise WrongUserRegistrationData('Missing user registration information.')
        
        if 'form.submitted' in request.params:
            # check if there is already a user with the same login registered in the database
            if not Users.by_username(login, dbsession):
                # register new user in the databse
                newUser = Users(login=login, password=password, email=email, vorname=vorname, nachname=nachname)
                dbsession.add(newUser)
    
                # define response header
                #userName = newUser.vorname+' '+newUser.nachname
                headers = remember(request, login)
                # get target url and route to it
                target_url = request.route_url('home_login',_query={'georef':'on'})
                transaction.commit()
                return HTTPFound(location = target_url, headers = headers)
        
    except WrongUserRegistrationData:
        raise 
    except:
        raise InternalAuthentificationError('Internal server error while trying to register user. Please try again or contact the page administrator.')
コード例 #4
0
def getPage_profileMtb(request):
    try:
        messtischblatt_id = None
        if 'objectid' in request.params:
            maps_id = request.params['objectid']
            log.info('Receive get map profile page for id %s.'%messtischblatt_id)
        
        georef = False
        if 'georef' in request.params and request.params['georef'].lower() == 'true':
            georef = True
        
        if georef:
            permalink = createPermalink(request, maps_id)
            return HTTPFound(location=permalink)
        
        mapObj = Map.by_id(maps_id, request.db)                
        metadata = Metadata.by_id(maps_id, request.db)        
        oai = createOAI(mapObj.id)
        
        return {'zoomify':metadata.imagezoomify,'key':oai,
                'titel_long': metadata.title,'titel_short': metadata.titleshort, 'permalink': metadata.apspermalink}
    except:
        log.error('Internal server error while trying to get profile page. Please try again or contact the page administrator.')
        log.error(traceback.format_exc())
        raise InternalAuthentificationError('Internal server error while trying to get profile page. Please try again or contact the page administrator.')
コード例 #5
0
ファイル: GetMapProfile.py プロジェクト: JSchwzr/vkviewer
def getPage_profileMtb(request):
    try:
        messtischblatt_id = None
        if 'objectid' in request.params:
            messtischblatt_id = request.params['objectid']
            log.info('Receive get map profile page for id %s.' %
                     messtischblatt_id)

        georef = False
        if 'georef' in request.params and request.params['georef'].lower(
        ) == 'true':
            georef = True

        if georef:
            permalink = createPermalink(request, messtischblatt_id)
            return HTTPFound(location=permalink)

        messtischblatt = Messtischblatt.by_id(messtischblatt_id, request.db)
        metadata = MdCore.by_id(messtischblatt.id, request.db)
        metadata_datensatz = MdDatensatz.by_ObjectId(messtischblatt.id,
                                                     request.db)
        return {
            'zoomify_prop': messtischblatt.zoomify_properties,
            'zoomify_width': messtischblatt.zoomify_width,
            'zoomify_height': messtischblatt.zoomify_height,
            'key': 'vk20-md-%s' % messtischblatt.id,
            'titel_long': metadata.titel,
            'titel_short': metadata.titel_short,
            'permalink': metadata_datensatz.permalink
        }
    except:
        log.error(
            'Internal server error while trying to get profile page. Please try again or contact the page administrator.'
        )
        raise InternalAuthentificationError(
            'Internal server error while trying to get profile page. Please try again or contact the page administrator.'
        )
コード例 #6
0
ファイル: Login.py プロジェクト: JSchwzr/vkviewer
    _ = request.translate
    dbsession = request.db

    try:
        login = request.params['username']
        password = request.params['password']
        user = Users.by_username(login, dbsession)
        if not password or not user:
            raise WrongLoginDataError(
                'The login data for user %s seems not to be valide, please try again.'
            )

        if 'form.submitted' in request.params:
            if user and user.validate_password(password):
                # define response header
                #userName = user.vorname+' '+user.nachname
                headers = remember(request, login)
                # get target url and route to it
                target_url = request.route_url('home_login',
                                               _query={'georef': 'on'})
                return HTTPFound(location=target_url, headers=headers)
            else:
                raise WrongPasswordError(
                    'Password for the user %s is not valid, please try again.')
    except WrongPasswordError, WrongLoginDataError:
        raise
    except:
        raise InternalAuthentificationError(
            'Internal server error while trying to login user. Please try again or contact the page administrator.'
        )