def signout(): if 'username' not in session: return redirect(url_for('signin')) session.pop('username', None) return redirect(url_for('home'))
def logout(): # Remove the current user from the session. if 'user_id' in session: session.pop('user_id', None) return empty_response else: return not_authorized
def AElimForo(): #GET parameter idForo = request.args['idForo'] results = [{'label':'/VForos', 'msg':['Foro eliminado']}, {'label':'/VForo', 'msg':['No se pudo eliminar el foro']}, ] res = results[0] #Action code goes here, res should be a list with a label and a message res['label'] =res['label'] + '/' + str(session['idUsuario']) foro = Foro.query.get(idForo) try: if session['idUsuario']==foro.autor: for publicacion in foro.publicacion: print(publicacion) db.session.delete(publicacion) db.session.delete(foro) db.session.commit() else: raise ValueError("No eres el dueño del foro") except ValueError as ve: res = results[1] res['label'] =res['label'] + '/' + idForo except: res = results[1] res['label'] =res['label'] + '/' + idForo finally: db.session.close() #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def ACrearObjetivo(): params = request.get_json() results = [{'label':'/VProducto', 'msg':['Objetivo creado']}, {'label':'/VCrearObjetivo', 'msg':['Error al crear objetivo']}, ] res = results[1] # Se obtiene el identificador del producto actual. idProducto = int(session['idPila']) # Parámetros del objetivo a crear. descripcion = params.get('descripcion', None) transversalidad = params.get('transversal', None) if ((transversalidad != None) and (descripcion!= None)): controlDeAcceso = clsControlDeAcceso() descripcionValida = controlDeAcceso.verificarDescripcion( descripcion ) if (descripcionValida): nuevoObjetivo = clsObjetivo() creacionCorrecta = nuevoObjetivo.insertar(idProducto, descripcion, transversalidad) if (creacionCorrecta): res = results[0] # Se actualiza el URL de la pág a donde se va a redirigir. res['label'] = res['label'] + '/' + str(idProducto) res['idPila'] = idProducto if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def AComentar(): #POST/PUT parameters params = request.get_json() results = [{'label':'/VPrincipal', 'msg':['Comentario realizado']}, {'label':'/VComentariosPagina', 'msg':['Error al realizar comentario']}, {'label':'/VPaginaSitio', 'msg':['Comentario realizado']}] res = results[0] #Action code goes here, res should be a list with a label and a message autor = session['idUsuario'] try: comentario = Publicacion(params['titulo'], params['contenido'], autor) sitio = PaginaSitio.query.get(session['idSitio']) if sitio.url!='/VPrincipal': res = results[2] res['label'] = res['label'] + '/' + str(session['idSitio']) sitio.publicacion.append(comentario) db.session.add(comentario) db.session.commit() except: res = results[1] res['label'] = res['label'] + '/' + str(session['idSitio']) finally: db.session.close() #En caso de error #res['label'] = res['label'] + '/' + repr(1) #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def ACrearEvento(): #Access to POST/PUT fields using request.form['name'] #Access to file fields using request.files['name'] params = request.form.copy() poster = request.files.get('afiche') if poster != None and archivo_permitido(poster.filename): filename = secure_filename(poster.filename) poster_path = os.path.join(subidas(), filename) poster.save(poster_path) params['afiche'] = poster_path evento = Evento(params) if evento and evento.save(): eventoid = Evento.ultimo() res = { 'label' : '/VEvento/'+str(eventoid), 'msg':[ur'Evento creado exitosamente.'] } else: res = { 'label' : '/VCrearEvento', 'msg':[ur'Error al crear el evento.'] } #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def AgregForo(): #POST/PUT parameters params = request.get_json() results = [{'label':'/VForos', 'msg':['Foro creado']}, {'label':'/VForos', 'msg':['No se pudo crear el foro']}, ] res = results[0] #Action code goes here, res should be a list with a label and a message idUsuario = session['idUsuario'] res['idUsuario'] = idUsuario titulo = params['titulo'] foro = Foro(titulo, idUsuario) try: #Se prueba el exito de la creacion del foro db.session.add(foro) db.session.commit() test = Foro.query.filter_by(titulo=titulo).first() x = test.titulo #Si Test es None esto dara error e ira al except except: res = results[1] finally: db.session.close() res['label'] = res['label'] + '/' + str(idUsuario) #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def AGenerarCredencial(): results = [{'label':'/VEvento', 'msg':[ur'Credencial generada']}, {'label':'/VEvento', 'msg':[ur'Error']}, ] eventoid = request.args.get('eventoid') if eventoid is None: res = results[1] else: evento = Evento.get(eventoid) usuario = session.get('actor') usuario = Usuario.get(usuario) if usuario is None: usuario = "Default" pdf = crear_pdf(render_template('credencial.html', evento=evento, usuario=usuario)) if pdf is None: res = results[1] else: res = results[0] res['credencial'] = pdf if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def AReservarEvento(): eventoid = request.args.get('eventoid') if eventoid is None: res = {'label':'/VEvento', 'msg':[ur'Error al reservar el evento']} else: user = session.get('actor') if user is None: user = "******" evento = Evento.get(eventoid) asiste = Asiste.get(user, evento.eventoid) if asiste is None and Evento.update(eventoid,{ 'capacidad' : evento.capacidad-1 }): asiste = Asiste(user, evento.eventoid) if asiste.save(): res = {'label':'/VEvento', 'msg':[ur'Evento reservado']} else: res = {'label':'/VEvento', 'msg':[ur'Error al reservar el evento']} else: res = {'label':'/VEvento', 'msg':[ur'Error al reservar el evento']} if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def AEditarEvento(): params = request.form.copy() poster = request.files.get('afiche') if poster != None and archivo_permitido(poster.filename): filename = secure_filename(poster.filename) poster_path = os.path.join(subidas(), filename) poster.save(poster_path) params['afiche'] = poster_path eventoid = params.pop('eventoid') results = [ {'label':'/VEvento/'+eventoid, 'msg':[ur'El evento fue editado exitosamente.']}, {'label':'/VEditarEvento/'+eventoid, 'msg':[ur'Error al editar el evento. Verifique los valores ingresados.']}, ] res = {} if Evento.update(eventoid,params): res = results[0] else: res = results[1] if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def AEliminarReserva(): eventoid = request.args.get('eventoid') if eventoid is None: res = {'label':'/VEvento', 'msg':[ur'Error']} else: user = session.get('actor') if user is None: user = "******" evento = Evento.get(eventoid) asiste = Asiste.get(user, evento.eventoid) if asiste is not None and evento.update(eventoid,{ 'capacidad' : evento.capacidad + 1 }): asiste.delete() res = {'label':'/VEvento', 'msg':[ur'Reserva eliminada.']} else: res = {'label':'/VEvento', 'msg':[ur'Error al eliminar la reserva.']} #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def signout(): if 'email' not in session and 'user_id' not in session: return redirect(url_for('signin')) session.pop('email', None) session.pop('user_id', None) return redirect('/')
def AConfirmarAsist(): res = {} evento = request.args.get('evento') usuario = request.args.get('usuario') # Obtener nombre del usuario usuario1 = usuario.split(':',1); usuario2 = usuario1[1].replace("{","") usuario3 = usuario2.replace("}","") user = usuario3.replace("\"","") # Obtener numero del evento evento1 = evento.split(':',1); evento2 = evento1[1].replace("{","") evento3 = evento2.replace("}","") eventoid = evento3.replace("\"","") if eventoid is None: res = {'label':'/VListarUsuarios/'+eventoid, 'msg':[ur'Error al confirmar la asistencia al evento.']} else: if Asiste.confirmarAsistencia(user,eventoid): res = {'label':'/VListarUsuarios/'+eventoid, 'msg':[ur'Asistencia confirmada.']} else: res = {'label':'/VListarUsuarios/'+eventoid, 'msg':[ur'Error al confirmar la asistencia al evento.']} #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def logout(): ''' Logout the user from the service. Ends the session ''' session.pop('openid', None) session.pop('user', None) return redirect(url_for('index'))
def after_login(resp): if resp.email is None or resp.email == "": flash('Invalid login. Please try again.') redirect(url_for('login')) user = User.query.filter_by(email = resp.email).first() if user is None: nickname = resp.nickname if nickname is None or nickname == "": nickname = resp.email.split('@')[0] nickname = User.make_unique_nickname(nickname) user = User(nickname = nickname, email = resp.email, role = ROLE_USER) models.session.add(user) models.session.commit() models.session.add(user.follow(user)) models.session.commit() remember_me = False if 'remember_me' in session: remember_me = session['remember_me'] session.pop('remember_me', None) login_user(user, remember = remember_me) return redirect(request.args.get('next') or url_for('demo')) remember_me = False if 'remember_me' in session: remember_me = session['remember_me'] session.pop('remember_me', None) login_user(user, remember = remember_me) return redirect(request.args.get('next') or url_for('demo'))
def gdisconnect(): credentials = login_session.get('credentials') print 'In gdisconnect access token is %s' % credentials.access_token print 'User name is: ' print login_session['username'] if credentials is None: print 'Access Token is None' response = make_response(json.dumps( 'Current user not connected.'), 401) response.headers['Content-Type'] = 'application/json' return response access_token = credentials.access_token url = 'https://accounts.google.com/o/oauth2/revoke?token=%s' % access_token print url h = httplib2.Http() result = h.request(url, 'GET')[0] print 'result is ' print result if result['status'] == '200': # del login_session['access_token'] login_session.pop('gplus_id', None) login_session.pop('username', None) login_session.pop('email', None) login_session.pop('picture', None) login_session.pop('user_id', None) response = make_response(json.dumps('Successfully disconnected.'), 200) response.headers['Content-Type'] = 'application/json' return response else: response = make_response(json.dumps( 'Failed to revoke token for given user.', 400)) response.headers['Content-Type'] = 'application/json' return response
def signout(): # Terminate sessions session.pop('id', None) # Not terminating a session for demo purpose/simplicity return redirect(url_for('index', quote='You are signed out'))
def AModificarPagina(): #POST/PUT parameters params = request.get_json() results = [{'label':'/VPagina', 'msg':['Cambios almacenados']}, ] res = results[0] #Action code goes here, res should be a list with a label and a message res['label'] = res['label'] + '/' + session['nombre_usuario'] contenido = "" if 'contenido' not in params else params['contenido'] pagina = (db.session.query(Pagina) .filter_by(id_usuario=session['nombre_usuario']) .first()) if pagina is None: pagina = Pagina(titulo=params['titulo'], contenido=contenido, usuario=session['nombre_usuario']) db.session.add(pagina) else: pagina.titulo = params['titulo'] pagina.contenido = contenido db.session.commit() #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def signout(): if 'email' not in session: return redirect(url_for('signin')) session.pop('email', None) return redirect(url_for('home'))
def search(): # url = 'https://www.googleapis.com/calendar/v3/users/me/calendarList' # data = None # response = json.dumps(google_calendar_request(url, data)) # print response # check if there is already an access token stored in session access_token = session.get('access_token') # if not, then redirect user to log in with google if access_token is None: return redirect(url_for('login')) # access_token is returned as a tuple, but since there is no secret, just use the first element access_token = access_token[0] # create header for the get request (a dictionary) headers = {'Authorization': 'OAuth ' + access_token} # urllib2.Request(url, data, headers) # HTTP request will be POST instead of GET when data provided # request to get a list of the user's google calendars req = urllib2.Request('https://www.googleapis.com/calendar/v3/users/me/calendarList', None, headers) try: # open a url, which can either be a string or Request object # urllib2.urlopen(url, data) res = urllib2.urlopen(req) except (urllib2.URLError,), e: if e.code == 401 or e.code == 403: # Unauthorized - bad token # delete token from session and redirect user to log in with google session.pop('access_token', None) return redirect(url_for('login')) # return the error code return str(e.code)
def commands(**options): from pajbot.models.command import CommandManager from pajbot.models.module import ModuleManager bot_commands = CommandManager( socket_manager=None, module_manager=ModuleManager(None).load(), bot=None).load(enabled=None) bot_commands_list = bot_commands.parse_for_web() custom_commands = [] point_commands = [] moderator_commands = [] for command in bot_commands_list: if command.id is None: continue if command.level > 100 or command.mod_only: moderator_commands.append(command) elif command.cost > 0: point_commands.append(command) else: custom_commands.append(command) with DBManager.create_session_scope() as db_session: commands_data = db_session.query(CommandData).options(joinedload(CommandData.user), joinedload(CommandData.user2)).all() return render_template( 'admin/commands.html', commands_data=commands_data, custom_commands=sorted(custom_commands, key=lambda f: f.command), point_commands=sorted(point_commands, key=lambda a: (a.cost, a.command)), moderator_commands=sorted(moderator_commands, key=lambda c: (c.level if c.mod_only is False else 500, c.command)), created=session.pop('command_created_id', None), edited=session.pop('command_edited_id', None))
def logout(): # remove the username from the session if it's there session.pop('email', None) session.pop('_id', None) if request.method == "POST": return redirect(url_for('root')) return redirect(url_for('root'))
def AActualizarEquipo(): #POST/PUT parameters params = request.get_json() results = [{'label':'/VEquipo', 'msg':['Equipo actualizado']}, {'label':'/VEquipo', 'msg':['Error al actualizar el equipo']}, ] res = results[1] #Action code goes here, res should be a list with a label and a message idPila = int(session['idPila']) lista = params['lista'] oTeam = team() exito = oTeam.actualizar(lista,idPila) if exito: res = results[0] res['label'] = res['label'] + '/' + repr(1) #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def logout(): """ Log the user out. """ session.pop('profile') session.pop('group') return redirect('/')
def signout(): if 'username' in session: pass session.pop('username', None) #flash('You were logged out') return redirect('/')
def AModifObjetivo(): params = request.get_json() results = [{'label':'/VProducto', 'msg':['Objetivo actualizado']}, {'label':'/VObjetivo', 'msg':['Error al modificar objetivo']}, ] res = results[1] # Se obtiene el identificador del producto actual. idProducto = int(session['idPila']) # Se obtiene los atributos del objetivo a modificar. identificador = int(params.get('idObjetivo')) descripcion = params.get('descripcion', None) transversalidad = params.get('transversal', None) if ((transversalidad != None) and (descripcion != None)): objetivo = clsObjetivo() modificacionCorrecta = objetivo.modificar(identificador, descripcion, transversalidad) if ( modificacionCorrecta ): res = results[0] res['label'] = res['label'] + '/' + str(idProducto) # Se actualiza el URL de la pág a donde se va a redirigir. if (res == results[1]): res['label'] = res['label'] + '/' + str(identificador) res['idPila'] = idProducto if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def sign_out(): if 'login' not in session: return redirect(url_for('sign_in')) session.pop('login', None) session.pop('shortener_user_urls', None) return redirect('/')
def add_project(): ''' Add a project. Default a tree structure and sections to go with them. ''' session.pop('project_id', None) form = ProjectForm(request.form) form.template.choices = [(t.id, t.name) for t in Project.query.order_by('name').filter(Project.is_template)] form.template.choices.insert(0, (0, gettext('-- Choose a Template --'))) if form.validate(): project = Project(name=form.name.data, description=form.description.data, is_template=form.is_template.data) db.session.add(project) if form.template.data != 0: copy_from_template(project, form.template.data) else: create_node(project=project, title=form.name.data) db.session.commit() session['project_id'] = project.id flash('New Project Added') return redirect(url_for('show_content', project_id=project.id, structure_id=None)) projects = Project.query.all() return render_template('index.html', projects=projects, form=form)
def AElimObjetivo(): #GET parameter identificador = int(request.args.get('idObjetivo',1)) idProducto = int(session['idPila']) results = [{'label':'/VProducto', 'msg':['Objetivo eliminado']}, {'label':'/VObjetivo', 'msg':['No se pudo eliminar este objetivo']}, ] res = results[1] objetivo = clsObjetivo() eliminarCorrecto = objetivo.eliminar(identificador) if(eliminarCorrecto): res = results[0] res['label'] = res['label'] + '/' + str(idProducto) if (res == results[1]): res['label'] = res['label'] + '/' + str(identificador) #Action code ends here if "actor" in res: if res['actor'] is None: session.pop("actor", None) else: session['actor'] = res['actor'] return json.dumps(res)
def gdisconnect(): # Only disconnect a connected user. credentials = login_session.get('credentials') print credentials if credentials is None: response = make_response( json.dumps('Current user not connected.'), 401) response.headers['Content-Type'] = 'application/json' return response print "this is a access token from credentials" print credentials.access_token access_token = login_session["credentials"].access_token url = 'https://accounts.google.com/o/oauth2/revoke?token=%s' % access_token h = httplib2.Http() result = h.request(url, 'GET')[0] print "Right before if statement" if result['status'] == '200': login_session.pop('access_token', None) del login_session['gplus_id'] del login_session['username'] del login_session['email'] response = make_response(json.dumps('Successfully disconnected.'), 200) response.headers['Content-Type'] = 'application/json' flash("You are now logged out.") return redirect(url_for('showTypes')) else: response = make_response(json.dumps( 'Failed to revoke token for given user.', 400)) response.headers['Content-Type'] = 'application/json' return response
def logout(): session.pop('user') return redirect('/dashboard')
def logout(self): session.pop('username', None) return redirect("/")
def logout(): response = app.make_response(redirect(request.referrer)) session.pop('user', None) return response
def logout(): session.pop('user', None) return redirect(url_for('index'))
def logout(): session.pop("username") return redirect(url_for("index"))
def logout(): session.pop('logged_in',None) flash('You were logged out') return redirect(url_for('login'))
def sessiontimeout(): session.pop("username", None) return redirect(url_for('register'))
def logout(): # 登出:清除字典的键值 session.pop('user',None) return redirect(url_for('login'))
def logout(): session.pop('user_id') return redirect(url_for('login'))
def logout(): #remove the username from the session session.pop('username', None) return "You've logged out." + render_template('product.html')
def sort_movies(sort_type): if "Title" in sort_type: movie_array = session['movies'] session.pop('movies') title_array = [] for i in movie_array: title_array.append(i[0][0]) title_array.sort() for count, item in enumerate(title_array): for j in movie_array: if j[0][0] == item: movie_array[movie_array.index(j)], movie_array[ count] = movie_array[count], movie_array[ movie_array.index(j)] if "A-Z" in sort_type: session['movies'] = movie_array if "Z-A" in sort_type: movie_array.reverse() session['movies'] = movie_array elif "Duration" in sort_type: movie_array = session['movies'] session.pop('movies') title_array = [] for i in movie_array: title_array.append(int(i[6][0])) title_array.sort() for count, item in enumerate(title_array): for j in movie_array: if int(j[6][0]) == item: movie_array[movie_array.index(j)], movie_array[ count] = movie_array[count], movie_array[ movie_array.index(j)] session['movies'] = movie_array elif "Release" in sort_type: movie_array = session['movies'] session.pop('movies') title_array = [] for i in movie_array: title_array.append(i[5][0]) title_array.sort() for count, item in enumerate(title_array): for j in movie_array: if j[5][0] == item: movie_array[movie_array.index(j)], movie_array[ count] = movie_array[count], movie_array[ movie_array.index(j)] session['movies'] = movie_array
def logout(): session.pop('UserID') return render_template('index.html ')
def logout(): log_http_request('/logout', 'get') session.pop('username', None) session.pop('ret_msg', None) return redirect(url_for('main'))
def loginout(): session.pop('name') session.pop('role') return redirect('/login')
def is_valid_state(state): state_is_valid = ('state' in session and len(session['state']) > 0 and session['state'] == state) session.pop('state', None) return state_is_valid
def logout(): session.pop('user',None) return redirect('/')
def logout(): session.pop('username') return redirect('/')
def logout(): """ logs user out by removing username from session, redirects to home page """ session.pop('username', None) return redirect(url_for('home_page'))
def logout(): session.pop('user_id', None) return redirect(oid.get_next_url())
def logout(): logout_user() session.pop('oauth_token', None) return redirect(url_for('users_template.login'))
def logout(): if current_user.is_authenticated: logout_user() session.pop('USERNAME', None) return redirect(url_for('default'))
def process_logout(): """Log user out.""" for key in session.keys(): session.pop(key) flash("Logged out.") return redirect("/")
def logout(): session.pop('account_name', None) return redirect(url_for('index'))
def logout(): session.pop('user_id', None) flash('You were logged out') return redirect(url_for('intmain'))
def logout(): session.pop("username", None) return render_template("index.html")
def logout(): # remove the username from the session if it is there session.pop('username', None) return redirect(url_for('index'))
def logout(): session.pop('access_token') return redirect('/login')
def logout(): session.pop('username', None) flash("logged out ! ") return redirect(url_for('index'))
def logout(): session.pop('username', None) return redirect("/login", 303)
def logout(): session.pop('userid', None) return render_template('login.html')