Subversion Repositories wimsdev

Rev

Rev 16004 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4561 obado 1
# AuthUser
2
# permet d'authentifier l'utilisateur quser dans la classe qclass
3
 
15427 obado 4
# On commence par verifier la classe $qclass
4667 obado 5
!read scripts/check.class
6
!if $error!=$empty
15427 obado 7
  !exit
4667 obado 8
!endif
9
 
5156 czzmrn 10
!if hashlogin iswordof $option
15427 obado 11
  quser_orig=$quser
12
  !read adm/class/hashlogin $quser_orig,$qclass,
13
  quser=$login
5156 czzmrn 14
!endif
15
 
15427 obado 16
# Puis on verifie l'existence de $quser
23 reyssat 17
!read scripts/check.user
18
!if $error!=$empty
15427 obado 19
  !if hashlogin iswordof $option
20
    error=hashlogin: $login
21
  !endif
22
  !exit
23 reyssat 23
!endif
24
 
25
!readdef $userdeffile
26
!if $qpasswd != $empty and $qpasswd != $user_password
15427 obado 27
  error=user authentification failure
28
  !exit
23 reyssat 29
!endif
30
 
15427 obado 31
wims_mode=$empty
23 reyssat 32
!readdef $classdeffile
33
 
13140 czzmrn 34
!if $class_type isitemof 2,4
15427 obado 35
  !default class_superclass=$wims_class
13140 czzmrn 36
!endif
3261 obado 37
!default class_typename=class
38
!default class_type=0
39
 
4590 obado 40
# Il faut tout d'abord verifier que l'utilisateur n'etait pas en session d'examen
41
parmreg=!record 0 of wimshome/log/classes/$wims_class/.parmreg/$quser.exam
42
nb_parms=!wordcnt $parmreg
43
 
44
### Schema du fichier .parmreg/user.exam ###
9750 obado 45
##
4590 obado 46
##    IP  SESS_ID   ??? exam_ID
47
## exemple : 134.59.121.121 UI99D09012 1315494761 3
48
##
49
############
50
 
51
num_session=$wims_session
52
 
15427 obado 53
# data1 doit contenir l'ip du user et non du serveur appelant
54
remote_addr=!word 1 of $data1
4629 obado 55
 
4590 obado 56
!if $nb_parms>=4
9750 obado 57
 
15427 obado 58
  !distribute words $parmreg into sess_IP,sess_ID,sess_time,exam_id
9750 obado 59
 
15427 obado 60
  !set r_=!record 0 of wimshome/sessions/$sess_ID/examreg.$exam_id
61
  !set now=$wims_nowseconds
4590 obado 62
 
15427 obado 63
  !set ws=!translate _ to $ $ in $wims_session
64
  !set ws=!word 1 of $ws
4590 obado 65
 
15427 obado 66
  !set restrictions=!record 0 of wimshome/log/classes/$wims_class/.E$exam_id
9750 obado 67
 
15427 obado 68
  # Check if user has changed his IP only if option $class_examscore_withoutip is active
69
  !if $class_examscore_withoutip!=yes
70
    # if a different exam session has started, is still pending
15856 czzmrn 71
    # ("$restrictions!=#" i.e. score registration open for all)
15427 obado 72
    !if $r_!=$empty and $sess_ID!=$ws and $sess_time>$now and $restrictions!=#
73
      !if $quser != supervisor and $sess_IP != $remote_addr
9750 obado 74
 
15427 obado 75
        !sh rm -f ../sessions/$ws/var.stat >/dev/null
76
        !if $remote_addr=$empty
77
          error= $quser is already in an exam session, but your server didn't provided the user actual IP in data1.
78
        !else
79
          error= $quser is in an exam session started on another IP. Go back quickly to this computer!
80
        !endif
81
        !exit
82
      !endif
83
      num_session=$sess_ID
84
    !endif
16004 czzmrn 85
  !else
86
    !if $r_!=$empty and $sess_ID!=$ws and $sess_time>$now and $restrictions!=#
87
      num_session=$sess_ID
88
    !endif
15427 obado 89
  !endif
9750 obado 90
 
15427 obado 91
  #si la session d'examen est terminee, on reinitialise les parametres de session
92
  !if $sess_time<$now or $r_=$empty
93
    !writefile wimshome/log/classes/$wims_class/.parmreg/$quser.exam
94
  !endif
4590 obado 95
 
96
!endif
97
 
98
dir_session=sessions/$num_session
99
 
4629 obado 100
!if $remote_addr!=$empty
15427 obado 101
  !setdef REMOTE_ADDR=$remote_addr in wimshome/$dir_session/var
4629 obado 102
!endif
103
 
104
 
5300 obado 105
!writefile wimshome/$dir_session/var.stat wims_class=$wims_class\
23 reyssat 106
wims_user=$quser\
107
wims_firstname=$user_firstname\
108
wims_lastname=$user_lastname\
109
wims_email=$user_email\
5141 czzmrn 110
wims_external_auth=$user_external_auth\
23 reyssat 111
wims_classname=$class_description\
112
wims_institutionname=$class_institution\
113
wims_supervisor=$class_supervisor\
391 obado 114
wims_supervisormail=$class_email\
8295 obado 115
wims_css=$class_css\
116
wims_theme=$class_theme\
8424 obado 117
wims_theme_icon=$class_theme_icon\
929 bpr 118
wims_participate=$user_participate\
4176 obado 119
wims_superclass=$class_superclass\
5303 obado 120
wims_supervise=$user_supervise\
3261 obado 121
wims_supertype=$class_type\
122
wims_typename=$class_typename
929 bpr 123
 
16436 czzmrn 124
!! for supervisors accessing via adm/raw
125
!! ./adm/class/authprep needs the variable sup_secure to be set
126
!!
127
!! (code from modules/home/var.auth and modules/adm/class/classes/var.auth)
128
!if $quser=supervisor
129
  sech=$class_secure
130
  sech=!trim $sech
131
  !if $sech=$empty
132
    t=0
133
  !else
134
    t=!checkhost $sech
135
    !if $t<1
136
      t=-1
137
    !endif
138
  !endif
139
  sup_secure=$t
140
!else
141
  !read ./adm/class/raftest
142
  !if $raftest>$lastallow
143
    !exit
144
  !endif
145
  sup_secure=-1
146
!endif
147
 
13154 czzmrn 148
!read ./adm/class/authprep $wims_class,$quser
149
!writefile wimshome/$wims_sesdir/var.stat $classdef
3261 obado 150
 
13154 czzmrn 151
!! the following not needed with lines above
152
!! !if $quser!=supervisor
153
!! !appendfile wimshome/$dir_session/var.stat wims_realuser=$quser
154
!! !endif
155
 
4118 obado 156
!if lightpopup iswordof $option
15427 obado 157
  !setdef wims_lightpopup=yes in wimshome/$dir_session/var.stat
158
  !setdef w_wims_lightpopup=yes in wimshome/$dir_session/var
4118 obado 159
!endif
3261 obado 160
 
4590 obado 161
!sh mkdir $wims_home/$dir_session/getfile
3261 obado 162
 
4590 obado 163
!sh ln -s $wims_home/log/classes/$qclass/src/images $wims_home/$dir_session/getfile/oefimages
13830 czzmrn 164
 
165
!if $quser=supervisor
15427 obado 166
  !! log supervisor access to class
167
  date=!translate : to . in $wims_now
168
  !appendfile wimshome/log/classes/$qclass/.log $date $httpd_REMOTE_ADDR      supervisor login via adm/raw
13830 czzmrn 169
!endif
170