2929
3030from __future__ import absolute_import
3131
32- # TODO: this backend is horribly KU/UCPH-specific, should move that to conf
32+ # TODO: this backend is somewhat KU/UCPH-specific, should move that to conf
3333
3434import os
3535import time
3636import tempfile
3737
3838from mig .shared import returnvalues
39- from mig .shared .accountreq import existing_country_code , forced_org_email_match , \
40- prefilter_potential_peers , user_manage_commands , save_account_request
39+ from mig .shared .accountreq import existing_country_code , \
40+ prefilter_potential_peers , save_account_request , signup_prefilter_allowed , \
41+ user_manage_commands
4142from mig .shared .accountstate import default_account_expire
4243from mig .shared .base import client_id_dir , canonical_user , mask_creds , \
4344 generate_https_urls , fill_distinguished_name
@@ -111,6 +112,7 @@ def main(client_id, user_arguments_dict):
111112 country = accepted ['country' ][- 1 ].strip ()
112113 state = accepted ['state' ][- 1 ].strip ()
113114 org = accepted ['org' ][- 1 ].strip ()
115+ # NOTE: safeinput thoroughly checks that emails are on valid form
114116 email = accepted ['email' ][- 1 ].strip ()
115117 password = accepted ['password' ][- 1 ]
116118 verifypassword = accepted ['verifypassword' ][- 1 ]
@@ -206,23 +208,6 @@ def main(client_id, user_arguments_dict):
206208 'class' : 'genericbutton' , 'text' : "Try again" })
207209 return (output_objects , returnvalues .CLIENT_ERROR )
208210
209- # TODO: move this check to conf?
210-
211- if not forced_org_email_match (org , email , configuration ):
212- output_objects .append ({'object_type' : 'error_text' , 'text' :
213- '''Illegal email and organization combination:
214- Please read and follow the instructions in red on the request page!
215- If you are a student with only a @*.ku.dk address please just use KU as
216- organization. As long as you state that you want the account for course
217- purposes in the comment field, you will be given access to the necessary
218- resources anyway.
219- ''' })
220- output_objects .append (
221- {'object_type' : 'link' ,
222- 'destination' : 'javascript:history.back();' ,
223- 'class' : 'genericbutton' , 'text' : "Try again" })
224- return (output_objects , returnvalues .CLIENT_ERROR )
225-
226211 raw_user = {
227212 'full_name' : cert_name ,
228213 'organization' : org ,
@@ -246,6 +231,19 @@ def main(client_id, user_arguments_dict):
246231 # Title name, lowercase email, uppercase country and state, etc.
247232 user_dict = canonical_user (configuration , raw_user , raw_user .keys ())
248233 fill_distinguished_name (user_dict )
234+
235+ if not signup_prefilter_allowed (configuration , raw_user ):
236+ output_objects .append ({'object_type' : 'error_text' , 'text' :
237+ '''Invalid sign up request:
238+ Please read and follow the sign up help and instructions on the request page!
239+ Namely, make sure to use the correct sign up based on your organizational
240+ affiliation. You may also read more about sign up in the site documentation.
241+ ''' })
242+ output_objects .append (
243+ {'object_type' : 'link' , 'destination' : 'javascript:history.back();' ,
244+ 'class' : 'genericbutton' , 'text' : "Try again" })
245+ return (output_objects , returnvalues .CLIENT_ERROR )
246+
249247 user_id = user_dict ['distinguished_name' ]
250248 user_dict ['authorized' ] = (user_id == client_id )
251249 if configuration .user_openid_providers and configuration .user_openid_alias :
@@ -285,7 +283,7 @@ def main(client_id, user_arguments_dict):
285283 helper_commands = user_manage_commands (configuration , mig_user , req_path ,
286284 user_id , user_dict , 'cert' )
287285 user_dict .update (helper_commands )
288- user_dict ['site' ] = configuration . short_title
286+ user_dict ['site' ] = short_title
289287 user_dict ['vgrid_label' ] = configuration .site_vgrid_label
290288 user_dict ['vgridman_links' ] = generate_https_urls (
291289 configuration , '%(auto_base)s/%(auto_bin)s/vgridman.py' , {})
0 commit comments