Exemplo n.º 1
0
def forgotten_password(request, **kwargs):
    request.session.modified = True
    
    template = "webadmin/forgotten_password.html"
    
    conn = None
    error = None
    blitz = None
    
    if request.method == 'POST':
        form = ForgottonPasswordForm(data=request.REQUEST.copy())
        if form.is_valid():
            blitz = Server.get(pk=request.REQUEST.get('server'))
            try:
                conn = getGuestConnection(blitz.host, blitz.port)
                if not conn.isForgottenPasswordSet():
                    error = "This server cannot reset password. Please contact your administrator."
                    conn = None
            except Exception, x:
                logger.error(traceback.format_exc())
                error = "Internal server error, please contact administrator."
        
            if conn is not None:
                try:
                    conn.reportForgottenPassword(smart_str(request.REQUEST.get('username')), smart_str(request.REQUEST.get('email')))
                    error = "Password was reseted. Check you mailbox."
                    form = None
                except Exception, x:
                    logger.error(traceback.format_exc())
                    error = "Internal server error, please contact administrator."
Exemplo n.º 2
0
 def setUp(self):
     super(AdminTests, self).setUp()
     
     c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
     try:
         root_password = c.ic.getProperties().getProperty('omero.rootpass')
         omero_host = c.ic.getProperties().getProperty('omero.host')
     finally:
         c.__del__()
     
     from omeroweb.webadmin.custom_models import Server
     server_id = Server.find(server_host=omero_host).id
     self.login('root', root_password, server_id)
Exemplo n.º 3
0
def getConnection(request):

    conn = None
    if request.session.get("username", None):
        logger.debug(
            "attempting to retrieve emdb connection with username:  %s" % request.session.get("username", None)
        )
        conn = getBlitzConnection(request, useragent="OMERO.webemdb")
        if not request.session.has_key("processors"):
            request.session["processors"] = {}
        if conn != None:
            logger.debug("emdb connection:  %s" % conn._sessionUuid)
    if conn == None:
        # session has timed out. Need to logout and log in again.
        try:
            _session_logout(request, request.session["server"])
        except:
            import traceback

            logger.debug("Failed to log out %s" % traceback.format_exc())
        server_id = request.REQUEST.get("server", None)
        if server_id is not None:
            blitz = Server.get(pk=int(server_id))
        else:
            blitz = Server.get(pk=1)
        logger.debug("attempting to connect emdb with blitz:  %s" % blitz)
        request.session["server"] = blitz.id
        request.session["host"] = blitz.host
        request.session["port"] = blitz.port
        request.session["password"] = "******"
        request.session["username"] = "******"
        request.session["processors"] = {}
        request.session.modified = True
        conn = getBlitzConnection(request, useragent="OMERO.webemdb")

        logger.debug("emdb connection: %s server %s" % (conn._sessionUuid, blitz.host))
    return conn
Exemplo n.º 4
0
def login (request):
    if request.method == 'POST' and request.REQUEST['server']:
        blitz = Server.get(pk=request.REQUEST['server'])
        request.session['server'] = blitz.id
        request.session['host'] = blitz.host
        request.session['port'] = blitz.port
    
    conn = getBlitzConnection (request, useragent="OMERO.webmobile")
    logger.debug(conn)
    
    url = request.REQUEST.get("url")
    
    if conn is None:
        return render_to_response('webmobile/login.html', {'gw':Server, 'url': url})
        
    if url is not None and len(url) != 0:
        return HttpResponseRedirect(url)
    else:
        return HttpResponseRedirect(reverse('webmobile_index'))
Exemplo n.º 5
0
def change_active_group(request, groupId, **kwargs):
    try:
        conn = kwargs["conn"]
    except:
        logger.error(traceback.format_exc())
        return handlerInternalError("Connection is not available. Please contact your administrator.")
    
    url = reverse('webmobile_index')
    
    server = request.session.get('server')
    username = request.session.get('username')
    password = request.session.get('password')
    ssl = request.session.get('ssl')
    version = request.session.get('version')
       
    webgateway_views._session_logout(request, request.session.get('server'))
    
    blitz = Server.get(pk=server) 
    request.session['server'] = blitz.id
    request.session['host'] = blitz.host
    request.session['port'] = blitz.port
    request.session['username'] = username
    request.session['password'] = password
    request.session['ssl'] = (True, False)[request.REQUEST.get('ssl') is None]
    request.session['clipboard'] = {'images': None, 'datasets': None, 'plates': None}
    request.session['shares'] = dict()
    request.session['imageInBasket'] = set()
    blitz_host = "%s:%s" % (blitz.host, blitz.port)
    request.session['nav']={"error": None, "blitz": blitz_host, "menu": "start", "view": "icon", "basket": 0, "experimenter":None, 'callback':dict()}
    
    #conn = getBlitzConnection(request, useragent="OMERO.webmobile")

    if conn.changeActiveGroup(groupId):
        request.session.modified = True                
    else:
        error = 'You cannot change your group becuase the data is currently processing. You can force it by logging out and logging in again.'
        url = reverse("webindex")+ ("?error=%s" % error)
        if request.session.get('nav')['experimenter'] is not None:
            url += "&experimenter=%s" % request.session.get('nav')['experimenter']
    
    request.session['version'] = conn.getServerVersion()
    
    return HttpResponseRedirect(url)   
Exemplo n.º 6
0
def change_active_group(request, groupId, conn=None, **kwargs):

    url = reverse('webmobile_index')
    
    server = request.session.get('server')
    username = request.session.get('username')
    password = request.session.get('password')
    ssl = request.session.get('ssl')
    version = request.session.get('version')
       
    webgateway_views._session_logout(request, request.session.get('server'))
    
    blitz = Server.get(pk=server) 
    request.session['server'] = blitz.id
    request.session['host'] = blitz.host
    request.session['port'] = blitz.port
    request.session['username'] = username
    request.session['password'] = password
    request.session['ssl'] = (True, False)[request.REQUEST.get('ssl') is None]
    request.session['clipboard'] = {'images': None, 'datasets': None, 'plates': None}
    request.session['shares'] = dict()
    request.session['imageInBasket'] = set()
    blitz_host = "%s:%s" % (blitz.host, blitz.port)
    request.session['nav']={"error": None, "blitz": blitz_host, "menu": "start", "view": "icon", "basket": 0, "experimenter":None, 'callback':dict()}
    
    #conn = getBlitzConnection(request, useragent="OMERO.webmobile")

    if conn.changeActiveGroup(groupId):
        request.session.modified = True                
    else:
        error = 'You cannot change your group becuase the data is currently processing. You can force it by logging out and logging in again.'
        url = reverse("webindex")+ ("?error=%s" % error)
        if request.session.get('nav')['experimenter'] is not None:
            url += "&experimenter=%s" % request.session.get('nav')['experimenter']
    
    request.session['version'] = conn.getServerVersion()
    
    return HttpResponseRedirect(url)   
Exemplo n.º 7
0
 def lookup_host_and_port(self):
     server = Server.get(self.server_id)
     if server is None:
         server = Server.find(server=self.server_id)
     return (server.host, server.port)