adapt client oidc
This commit is contained in:
parent
7a128e6e7f
commit
7b2bfd095c
|
@ -41,30 +41,22 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<nav class="header-nav ms-auto">
|
|
||||||
|
<section class="container mt-3">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<nav class="header-nav ms-auto">
|
||||||
<ul class="d-flex align-items-right">
|
<ul class="d-flex align-items-right">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
{% if user.is_anonymous %}
|
{% if not rols and user.is_anonymous %}
|
||||||
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#validateModal">Validate</button>
|
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#validateModal">Validate</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button class="btn btn-primary" id="buttonRol" data-bs-toggle="modal" data-bs-target="#rolsModal">Select your rol</button>
|
<button class="btn btn-primary" id="buttonRol" data-bs-toggle="modal" data-bs-target="#rolsModal">Select your rol</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{ rol }}
|
</nav>
|
||||||
</nav>
|
|
||||||
|
|
||||||
<section class="container mt-3">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
{% if not rol and rols %}
|
|
||||||
<button class="btn btn-primary">Select a Rol</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
<div class="col">
|
|
||||||
<div class="col-xl-12">
|
<div class="col-xl-12">
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
@ -236,7 +228,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if user.is_anonymous %}
|
{% if user.is_anonymous and not rols %}
|
||||||
<div class="modal fade" id="validateModal" tabindex="-1" style="display: none;" aria-hidden="true">
|
<div class="modal fade" id="validateModal" tabindex="-1" style="display: none;" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -250,10 +242,13 @@
|
||||||
<a class="btn btn-primary" type="button"
|
<a class="btn btn-primary" type="button"
|
||||||
href="{{ url_for('core.login') }}?next={{ device_real.url.to_text() }}">
|
href="{{ url_for('core.login') }}?next={{ device_real.url.to_text() }}">
|
||||||
User of system
|
User of system
|
||||||
</a> <br />
|
|
||||||
<a class="btn btn-primary mt-3" type="button" href="#">
|
|
||||||
User with Metamax Wallet
|
|
||||||
</a>
|
</a>
|
||||||
|
{% if oidc %}
|
||||||
|
<br />
|
||||||
|
<a class="btn btn-primary mt-3" type="button" href="{{ url_for('oidc.login_other_inventory') }}?next={{ device_real.url.to_text() }}">
|
||||||
|
User of other inventory
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer"></div>
|
<div class="modal-footer"></div>
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import datetime
|
import datetime
|
||||||
import uuid
|
|
||||||
from itertools import filterfalse
|
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
import marshmallow
|
import marshmallow
|
||||||
from ereuseapi.methods import API
|
from ereuseapi.methods import API
|
||||||
|
@ -10,14 +7,12 @@ from flask import current_app as app
|
||||||
from flask import g, render_template, request, session
|
from flask import g, render_template, request, session
|
||||||
from flask.json import jsonify
|
from flask.json import jsonify
|
||||||
from flask_sqlalchemy import Pagination
|
from flask_sqlalchemy import Pagination
|
||||||
from marshmallow import Schema as MarshmallowSchema
|
|
||||||
from marshmallow import fields
|
from marshmallow import fields
|
||||||
from marshmallow import fields as f
|
from marshmallow import fields as f
|
||||||
from marshmallow import validate as v
|
from marshmallow import validate as v
|
||||||
from sqlalchemy.util import OrderedSet
|
from sqlalchemy.util import OrderedSet
|
||||||
from teal import query
|
from teal import query
|
||||||
from teal.cache import cache
|
from teal.cache import cache
|
||||||
from teal.db import ResourceNotFound
|
|
||||||
from teal.marshmallow import ValidationError
|
from teal.marshmallow import ValidationError
|
||||||
from teal.resource import View
|
from teal.resource import View
|
||||||
|
|
||||||
|
@ -30,7 +25,6 @@ from ereuse_devicehub.resources.action.models import Trade
|
||||||
from ereuse_devicehub.resources.device import states
|
from ereuse_devicehub.resources.device import states
|
||||||
from ereuse_devicehub.resources.device.models import Computer, Device, Manufacturer
|
from ereuse_devicehub.resources.device.models import Computer, Device, Manufacturer
|
||||||
from ereuse_devicehub.resources.device.search import DeviceSearch
|
from ereuse_devicehub.resources.device.search import DeviceSearch
|
||||||
from ereuse_devicehub.resources.enums import SnapshotSoftware
|
|
||||||
from ereuse_devicehub.resources.lot.models import LotDeviceDescendants
|
from ereuse_devicehub.resources.lot.models import LotDeviceDescendants
|
||||||
from ereuse_devicehub.resources.tag.model import Tag
|
from ereuse_devicehub.resources.tag.model import Tag
|
||||||
|
|
||||||
|
@ -138,9 +132,13 @@ class DeviceView(View):
|
||||||
return self.one_private(id)
|
return self.one_private(id)
|
||||||
|
|
||||||
def get_rols(self):
|
def get_rols(self):
|
||||||
if not g.user.is_authenticated:
|
rols = session.get('rols')
|
||||||
|
if not g.user.is_authenticated and not rols:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
if rols:
|
||||||
|
return [(k, k) for k in rols]
|
||||||
|
|
||||||
if 'trublo' not in app.blueprints.keys():
|
if 'trublo' not in app.blueprints.keys():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -184,8 +182,10 @@ class DeviceView(View):
|
||||||
placeholder = device.binding or device.placeholder
|
placeholder = device.binding or device.placeholder
|
||||||
device_abstract = placeholder and placeholder.binding or device
|
device_abstract = placeholder and placeholder.binding or device
|
||||||
device_real = placeholder and placeholder.device or device
|
device_real = placeholder and placeholder.device or device
|
||||||
|
oidc = 'oidc' in app.blueprints.keys()
|
||||||
return render_template(
|
return render_template(
|
||||||
'devices/layout.html',
|
'devices/layout.html',
|
||||||
|
oidc=oidc,
|
||||||
placeholder=placeholder,
|
placeholder=placeholder,
|
||||||
device=device,
|
device=device,
|
||||||
device_abstract=device_abstract,
|
device_abstract=device_abstract,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import flask
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
from flask import g
|
from flask import g, session
|
||||||
from flask.views import View
|
from flask.views import View
|
||||||
from flask_login import current_user, login_required, login_user, logout_user
|
from flask_login import current_user, login_required, login_user, logout_user
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
|
@ -64,6 +64,8 @@ class LoginView(View):
|
||||||
|
|
||||||
class LogoutView(View):
|
class LogoutView(View):
|
||||||
def dispatch_request(self):
|
def dispatch_request(self):
|
||||||
|
session_vars = ['token_dlt', 'rols']
|
||||||
|
[session.pop(i, '') for i in session_vars]
|
||||||
logout_user()
|
logout_user()
|
||||||
return flask.redirect(flask.url_for('core.login'))
|
return flask.redirect(flask.url_for('core.login'))
|
||||||
|
|
||||||
|
|
Reference in New Issue