Skip to content

Commit

Permalink
YDA-5550: Suitable error message for PAM users who are not in iRODS
Browse files Browse the repository at this point in the history
  • Loading branch information
claravox committed Nov 29, 2023
1 parent f87e455 commit 507a2c0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
48 changes: 47 additions & 1 deletion user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@

import jwt
import requests
from flask import Blueprint, current_app as app, flash, g, redirect, render_template, request, Response, session, url_for
from flask import (
Blueprint,
current_app as app,
flash,
g,
redirect,
render_template,
request,
Response,
session,
url_for,
Markup
)
from irods.exception import CAT_INVALID_AUTHENTICATION, CAT_INVALID_USER, iRODSException, PAM_AUTH_PASSWORD_FAILED
from irods.session import iRODSSession

Expand Down Expand Up @@ -92,6 +104,40 @@ def login() -> Response:
log_error("iRODS authentication failed for user " + username)
return render_template('user/login.html', login_placeholder=get_login_placeholder())

except CAT_INVALID_USER:
first_message = 'Your user is not part of the Yoda system (yet).'
website_message = (f'Go to <a href="{app.config.get("LOGIN_HELP_CONTACT_WEBSITE")}" '
'class="alert-link">this</a> page to learn about gaining access.')
email_message = (f'Contact <a href="mailto:{app.config.get("LOGIN_HELP_CONTACT_EMAIL")}" '
'class="alert-link">this</a> email for help getting access.')

if (app.config.get("LOGIN_HELP_CONTACT_WEBSITE") and app.config.get("LOGIN_HELP_CONTACT_EMAIL")):
message = Markup(
f'{first_message} '
f'{website_message} '
f'{email_message}'
)
elif (app.config.get("LOGIN_HELP_CONTACT_WEBSITE")):
message = Markup(
f'{first_message} '
f'{website_message}'
)
elif (app.config.get("LOGIN_HELP_CONTACT_EMAIL")):
message = Markup(
f'{first_message} '
f'{email_message}'
)
else:
message = Markup(
f'{first_message}'
)
flash(
message,
'danger')

log_error("iRODSException CAT_INVALID_USER for login of user " + str(username), True)
return render_template('user/login.html', login_placeholder=get_login_placeholder())

except iRODSException:
flash(
'An error occurred while connecting to iRODS. '
Expand Down
2 changes: 1 addition & 1 deletion vault/static/vault/js/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ function topInformation (dir, showAlert) {
{ quiet: true, rawResult: true }).then((dataRaw) => {
const data = dataRaw.data
if (dataRaw.status === 'error_nonexistent') {
Yoda.set_message('error', 'This vault space path does not exists: ' + dir)
Yoda.set_message('error', 'This vault space path does not exist: ' + dir)
$('#file-browser_wrapper').addClass('hide')
$('.top-information').addClass('hide')

Expand Down

0 comments on commit 507a2c0

Please sign in to comment.