From 10c53a80966df4d8222a1f9262a52fd86233dfff Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sat, 26 Dec 2015 15:37:46 +0100 Subject: [PATCH] On logout display the number of sessions we are logged out from (none, 1, more). --- cas_server/locale/en/LC_MESSAGES/django.mo | Bin 4686 -> 5911 bytes cas_server/locale/en/LC_MESSAGES/django.po | 65 ++++++++++++++------ cas_server/locale/fr/LC_MESSAGES/django.mo | Bin 6235 -> 7039 bytes cas_server/locale/fr/LC_MESSAGES/django.po | 64 +++++++++++++------ cas_server/templates/cas_server/logout.html | 2 +- cas_server/views.py | 43 +++++++++++-- 6 files changed, 132 insertions(+), 42 deletions(-) diff --git a/cas_server/locale/en/LC_MESSAGES/django.mo b/cas_server/locale/en/LC_MESSAGES/django.mo index c0307293f448d41231addb4d5814e60949c7e20f..17ed8712031b79fed06accb8f43839140f10ac6f 100644 GIT binary patch literal 5911 zcmeI0ON-9bAtFPzcvfDpmxQ0yHLP&AeO|uygm$WLA?xa1uf`xp^%OK6a{BFjeDz*~b1#<8ZC_!p}7KG^RtGxaVNc}E?_kox4_dkL( z|F7VBaPXdN+*d&f8@&#aUCu!mvP%t}kAXjfq{nw41li>{NOsxxKxU73bDjmsF1J0% z*iNtvlAhlLssG0y+2vGTKL?UsE`Vg0UqEWV0gX0*&w*r@X^`}F8oUI44U&9cJe1k# z3`ll42a;WW14(~dpg-2VHO-_IP@i z=_)@R21>VCL&4=tB+V7sUwp29%?w(vgKmY>ZY9XXINtRpDH zsNjfnmW}B+mVqPfbUVU$EUJ;@2PgJl<0Iq7z-vNm!a0|q%}pD-r!V)Uep@c|^hs*k zZ`pObShhEw7Lf{R5EXN5d#sF2s3x3*giSpao~GNG6@&Rpjuf1uW%RTP$!d}sG6W_L z|DFvt=+2vD&@AB4djunbis=^(+4Hm`@<=2cG*qQf1zFn-6*N-yV4aDab;sP77Vbz2 zH6peo1$?U`2*Opfh3K^{lXl_0*@UUrWBaJu49DidMu^!Y3~OZ?OR?}tqmRzy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/.*$'.As it is a regular expression, special " "character must be escaped with a '\\'." msgstr "" +"A regular expression matching services. Will usually looks like '^https://" +"some\\.server\\.com/path/.*$'.As it is a regular expression, special " +"character must be escaped with a '\\'." #: models.py:198 msgid "user field" @@ -210,7 +213,7 @@ msgstr "" #: templates/cas_server/logged.html:10 msgid "Log me out from all my sessions" -msgstr "" +msgstr "Log me out from all my sessions" #: templates/cas_server/logged.html:13 msgid "Logout" @@ -224,54 +227,80 @@ msgstr "Please loggin" msgid "Login" msgstr "Login" -#: templates/cas_server/logout.html:6 views.py:123 -msgid "Successfully logout" -msgstr "" -"

Logout successful

You have successfully logged out of the Central " -"Authentication Service.
For security reasons, exit your web browser." - #: templates/cas_server/warn.html:7 msgid "Connect to the service" msgstr "Connect to the service" -#: views.py:197 +#: views.py:128 +msgid "" +"

Logout successful

You have successfully logged out from the Central " +"Authentication Service. For security reasons, exit your web browser." +msgstr "" +"

Logout successful

You have successfully logged out from the Central " +"Authentication Service. For security reasons, exit your web browser." + +#: views.py:134 +#, python-format +msgid "" +"

Logout successful

You have successfully logged out from %s sessions " +"of the Central Authentication Service. For security reasons, exit your web " +"browser." +msgstr "" +"

Logout successful

You have successfully logged out from %s sessions " +"of the Central Authentication Service. For security reasons, exit your web " +"browser." + +#: views.py:141 +msgid "" +"

Logout successful

You were already logged out from the Central " +"Authentication Service. For security reasons, exit your web browser." +msgstr "" +"

Logout successful

You were already logged out from the Central " +"Authentication Service. For security reasons, exit your web browser." + +#: views.py:230 msgid "Invalid login ticket" msgstr "Invalid login ticket, please retry to login" -#: views.py:292 +#: views.py:325 #, python-format msgid "Authentication has been required by service %(name)s (%(url)s)" msgstr "Authentication has been required by service %(name)s (%(url)s)" -#: views.py:326 +#: views.py:359 #, python-format msgid "Service %(url)s non allowed." msgstr "Service %(url)s non allowed." -#: views.py:333 +#: views.py:366 msgid "Username non allowed" msgstr "Username non allowed" -#: views.py:340 +#: views.py:373 msgid "User charateristics non allowed" msgstr "User charateristics non allowed" -#: views.py:347 +#: views.py:380 #, python-format msgid "The attribut %(field)s is needed to use that service" msgstr "The attribut %(field)s is needed to use that service" -#: views.py:417 +#: views.py:450 #, python-format msgid "Authentication renewal required by service %(name)s (%(url)s)." msgstr "Authentication renewal required by service %(name)s (%(url)s)." -#: views.py:424 +#: views.py:457 #, python-format msgid "Authentication required by service %(name)s (%(url)s)." msgstr "Authentication required by service %(name)s (%(url)s)." -#: views.py:431 +#: views.py:464 #, python-format msgid "Service %s non allowed" msgstr "Service %s non allowed" + +#~ msgid "Successfully logout" +#~ msgstr "" +#~ "

Logout successful

You have successfully logged out of the Central " +#~ "Authentication Service.
For security reasons, exit your web browser." diff --git a/cas_server/locale/fr/LC_MESSAGES/django.mo b/cas_server/locale/fr/LC_MESSAGES/django.mo index d1fab0f2a272ded8037f81355d78e55f7d459e4d..92342890b7fa3f551f36f284f2204b9acb6d2477 100644 GIT binary patch delta 1831 zcmb`{TWAzl7{Kvwlg&nJV%%igrZ+trFReAJ=CX;YRcg{wVnswKS}?HgPBtrR2Ii8O z(y~6ZPem#nZ0S>dv5?S*;G*lo zUco**-YBvIzl?o=Ir_OJBK*lwepccHGQTRPXtXl$MKmCn@M-$rVHe&*ov?PPNCpS- zWjuhZ@MGlNavoWmT#Wm3*iZi(dW;p~7QBgRyo)_3 z%S4VqFA@wnjkMW0;}Gwcei|eAF6xBqNYvz~ zxId5j;QR6T@2Cq(vJG9}Hq`rfBWsoYsLvU}jaWim@JIL|>HP%H(ci!>tDn=jL1P-< zTMte-($Yhy3irDcptMqK0&NTht%MHS|y5YMez);Z=MR=kYmgAWV9;I&eF> z8R9=kW0rvfxPa?%&*LHqR_YYi}q1Cm1-y0O^rCs1JOA20NY-A=)y8x}$xlp{<~PF+S?NS=0~a0uJL> zvCEjG^WQ{GVF7i1Iqo~v_=aP+lMC;o9;(Y2o&nSx&&NK*e){QWqBAgz1SaIz5_^Cp8pftyt zU(LA|6aGert}RF;+p3xr{qLb=6P56BgvPpeykVDY-!raXC|IsL>Q}aJX7r%#o3Z?a zwP?IDWh!>5WEG9xKkC>=%{te(Oe)*suCYgrH)feZYut1474wQuZ`>;v@*bB>Fq>+u zX3cB1!;FIOl)WkASb3M3n~Zg=?3pRscg&=9*c^83N!N0+|9N$fE+;sXYW;uLFljlK z$yeA&@t?tY^z~shf|*ov_TR;!_I+}9vevisR$XIP&TQ=+=nmF5tzHthdun@|S`xwQ znU%q%^on3IlTKTI%S+KW!Nry}by*Xf&ForqV=l3Hq@j6k+ACXco8sK`k-5{sM5Zsg PUK?q?ovJNlO7(vN85A+9 delta 1310 zcmXxkOGwmF6vy#1xIH8MVinRpG$@g{2i6U@gq&iFHy zm?i8Fod{nPWGqiOfCY^EaTlJ$_4pL|Q=3BGX>-o_3o7~V*n(BOy#{+Q2d`roZ=*K& z3YE}2dU?OOvdnxu@Sz_ou>oT^h;d}o_8yhU3@X9Ds6>3(%i|(sO{+#F5Ji38hnhc# zdvOT6@eyY7e)F$3BY7)DEf7LY3_H*3Q3Jq*a-6SG zJMN|&KX3$lm9W*jJU)vX7(c@boI}pc+<9h2ScYX7#SZMkoj8tr za1M`Rh^(vdJi16|0x6!|&8PmXX%Dy=n)n?1@E>l&9?qi>uV54>a1(w+CFJHDc!!0M zDHg^1*pAxaZ@i36EJ6|NC2HMw7{tXw>c56gkost6VN@yGu^Bs26EC5D5I683jyZls z&5uwH9a$S{{yt}X81?-TY{TQIJ9Gzij>4N zhEP+QYTCCBbLlsMWNw=Y-5|=ebOXYugVX6Z5}czI6Kd4I+&0qDzm2G#&~&}jI7rJ= ziUsxb*69&Vx1B;+>T&uZkH2fAxA(;GaQ{d=ekK?n8W\n" "Language-Team: django \n" "Language: fr\n" @@ -236,61 +236,89 @@ msgstr "Merci de se connecter" msgid "Login" msgstr "Connexion" -#: templates/cas_server/logout.html:6 views.py:123 -msgid "Successfully logout" -msgstr "" -"

Déconnexion réussie

\n" -"Vous vous êtes déconnecté(e) du Service Central d'Authentification.
Pour " -"des raisons de sécurité, veuillez fermer votre navigateur." - #: templates/cas_server/warn.html:7 msgid "Connect to the service" msgstr "Se connecter au service" -#: views.py:197 +#: views.py:128 +msgid "" +"

Logout successful

You have successfully logged out from the Central " +"Authentication Service. For security reasons, exit your web browser." +msgstr "" +"

Déconnexion réussie

Vous vous êtes déconnecté(e) du Service Central " +"d'Authentification. Pour des raisons de sécurité, veuillez fermer votre " +"navigateur." + +#: views.py:134 +#, python-format +msgid "" +"

Logout successful

You have successfully logged out from %s sessions " +"of the Central Authentication Service. For security reasons, exit your web " +"browser." +msgstr "" +"

Déconnexion réussie

Vous vous êtes déconnecté(e) de %s sessions du " +"Service Central d'Authentification. Pour des raisons de sécurité, veuillez " +"fermer votre navigateur." + +#: views.py:141 +msgid "" +"

Logout successful

You were already logged out from the Central " +"Authentication Service. For security reasons, exit your web browser." +msgstr "" +"

Déconnexion réussie

Vous étiez déjà déconnecté(e) du Service Central " +"d'Authentification. Pour des raisons de sécurité, veuillez fermer votre " +"navigateur." + +#: views.py:230 msgid "Invalid login ticket" msgstr "Ticket de connexion invalide, merci de réessayé de vous connecter" -#: views.py:292 +#: views.py:325 #, python-format msgid "Authentication has been required by service %(name)s (%(url)s)" msgstr "" "Une demande d'authentification a été émise pour le service %(name)s " "(%(url)s)." -#: views.py:326 +#: views.py:359 #, python-format msgid "Service %(url)s non allowed." msgstr "le service %(url)s n'est pas autorisé." -#: views.py:333 +#: views.py:366 msgid "Username non allowed" msgstr "Nom d'utilisateur non authorisé" -#: views.py:340 +#: views.py:373 msgid "User charateristics non allowed" msgstr "Caractéristique utilisateur non autorisée" -#: views.py:347 +#: views.py:380 #, python-format msgid "The attribut %(field)s is needed to use that service" msgstr "L'attribut %(field)s est nécessaire pour se connecter à ce service" -#: views.py:417 +#: views.py:450 #, python-format msgid "Authentication renewal required by service %(name)s (%(url)s)." msgstr "Demande de réauthentification pour le service %(name)s (%(url)s)." -#: views.py:424 +#: views.py:457 #, python-format msgid "Authentication required by service %(name)s (%(url)s)." msgstr "Authentification requise par le service %(name)s (%(url)s)." -#: views.py:431 +#: views.py:464 #, python-format msgid "Service %s non allowed" msgstr "Le service %s n'est pas autorisé" +#~ msgid "Successfully logout" +#~ msgstr "" +#~ "

Déconnexion réussie

\n" +#~ "Vous vous êtes déconnecté(e) du Service Central d'Authentification.
Pour des raisons de sécurité, veuillez fermer votre navigateur." + #~ msgid "" #~ "A ProxyGrantingTicket can be delivered to the service in order to " #~ "authenticate for the user on a backend service" diff --git a/cas_server/templates/cas_server/logout.html b/cas_server/templates/cas_server/logout.html index 9de1276..f189866 100644 --- a/cas_server/templates/cas_server/logout.html +++ b/cas_server/templates/cas_server/logout.html @@ -3,6 +3,6 @@ {% load staticfiles %} {% load i18n %} {% block content %} - + {% endblock %} diff --git a/cas_server/views.py b/cas_server/views.py index 6ef944b..273da55 100644 --- a/cas_server/views.py +++ b/cas_server/views.py @@ -64,6 +64,7 @@ class LogoutMixin(object): """destroy CAS session utils""" def logout(self, all=False): """effectively destroy CAS session""" + session_nb = 0 username = self.request.session.get("username") if username: if all: @@ -79,6 +80,7 @@ class LogoutMixin(object): self.request.session.flush() user.logout(self.request) user.delete() + session_nb += 1 except models.User.DoesNotExist: # if user not found in database, flush the session anyway self.request.session.flush() @@ -90,7 +92,9 @@ class LogoutMixin(object): session.flush() user.logout(self.request) user.delete() + session_nb += 1 logger.info("User %s logged out" % username) + return session_nb class LogoutView(View, LogoutMixin): @@ -109,7 +113,7 @@ class LogoutView(View, LogoutMixin): """methode called on GET request on this view""" logger.info("logout requested") self.init_get(request) - self.logout(self.request.GET.get("all")) + session_nb = self.logout(self.request.GET.get("all")) # if service is set, redirect to service after logout if self.service: list(messages.get_messages(request)) # clean messages before leaving the django app @@ -119,20 +123,49 @@ class LogoutView(View, LogoutMixin): return HttpResponseRedirect(self.url) # else redirect to login page else: + if session_nb == 1: + logout_msg = _( + "

Logout successful

" + "You have successfully logged out from the Central Authentication Service. " + "For security reasons, exit your web browser." + ) + elif session_nb > 1: + logout_msg = _( + "

Logout successful

" + "You have successfully logged out from %s sessions of the Central " + "Authentication Service. " + "For security reasons, exit your web browser." + ) % session_nb + else: + logout_msg = _( + "

Logout successful

" + "You were already logged out from the Central Authentication Service. " + "For security reasons, exit your web browser." + ) + if settings.CAS_REDIRECT_TO_LOGIN_AFTER_LOGOUT: - messages.add_message(request, messages.SUCCESS, _(u'Successfully logout')) + messages.add_message(request, messages.SUCCESS, logout_msg) if self.ajax: url = reverse("cas_server:login") - data = {'status': 'success', 'detail': 'logout', 'url': url} + data = { + 'status': 'success', + 'detail': 'logout', + 'url': url, + 'session_nb': session_nb + } return JsonResponse(request, data) else: return redirect("cas_server:login") else: if self.ajax: - data = {'status': 'success', 'detail': 'logout'} + data = {'status': 'success', 'detail': 'logout', 'session_nb': session_nb} return JsonResponse(request, data) else: - return render(request, settings.CAS_LOGOUT_TEMPLATE) + return render( + request, + settings.CAS_LOGOUT_TEMPLATE, + {'logout_msg': logout_msg} + ) class LoginView(View, LogoutMixin):