bzr branch
http://gegoxaren.bato24.eu/bzr/magstudentportal/trunk
|
18
by Gustav Hartvigsson
* Added vim modelines |
1 |
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
|
2 |
* vi: set shiftwidth=2 tabstop=2 expandtab:
|
|
3 |
* :indentSize=2:tabSize=2:noTabs=true:
|
|
4 |
*/
|
|
5 |
||
|
15.1.7
by Gustav Hartvigsson
* added a few things that will help with development |
6 |
package beans; |
7 |
||
|
27
by Gustav Hartvigsson
* changed DB -> db |
8 |
import common.*; |
9 |
import db.*; |
|
10 |
||
|
15.2.2
by Gustav Hartvigsson
* Added JUnit and javax.faces dependancies to the pom.xml. |
11 |
import javax.faces.bean.*; |
|
22
by Gustav Hartvigsson
* made the @Inject work. |
12 |
import javax.inject.Inject; |
|
21
by Gustav Hartvigsson
* Started work on the login bean... I have no Ida what I am doing. |
13 |
import javax.persistence.*; |
|
15.2.7
by Gustav Hartvigsson
* Started work on design |
14 |
|
|
15.1.7
by Gustav Hartvigsson
* added a few things that will help with development |
15 |
|
|
15.2.2
by Gustav Hartvigsson
* Added JUnit and javax.faces dependancies to the pom.xml. |
16 |
@ManagedBean
|
|
15.1.7
by Gustav Hartvigsson
* added a few things that will help with development |
17 |
@SessionScoped
|
18 |
public class |
|
19 |
LoginBean { |
|
|
21
by Gustav Hartvigsson
* Started work on the login bean... I have no Ida what I am doing. |
20 |
|
21 |
private String pw_hash; |
|
22 |
private String user_name; |
|
23 |
||
|
22
by Gustav Hartvigsson
* made the @Inject work. |
24 |
@Inject |
25 |
EntityManager em; |
|
26 |
||
27 |
private boolean is_logged_in = false; |
|
28 |
||
29 |
private UserTypeEnum user_type = UserTypeEnum.NONE; |
|
|
15.2.7
by Gustav Hartvigsson
* Started work on design |
30 |
|
|
21
by Gustav Hartvigsson
* Started work on the login bean... I have no Ida what I am doing. |
31 |
/****************************************************************************/
|
32 |
||
33 |
public void |
|
34 |
setPassword (String s) { |
|
35 |
this.pw_hash = Utils.hash_func(s); |
|
36 |
} |
|
37 |
||
38 |
public String |
|
39 |
getPassword () { |
|
40 |
return null; |
|
41 |
} |
|
42 |
||
43 |
public void |
|
44 |
setUserName (String s) { |
|
45 |
this.user_name = s; |
|
46 |
} |
|
47 |
||
48 |
public UserTypeEnum |
|
49 |
getUserType () { |
|
50 |
return this.user_type; |
|
51 |
} |
|
52 |
/****************************************************************************/
|
|
53 |
||
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
54 |
public String |
|
21
by Gustav Hartvigsson
* Started work on the login bean... I have no Ida what I am doing. |
55 |
studentLogin () { |
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
56 |
if (this.is_logged_in) { |
57 |
return "success"; |
|
58 |
} |
|
|
28
by Gustav Hartvigsson
* fixed compile errors. |
59 |
Student stnt = em.find(Student.class, this.user_name); |
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
60 |
if (stnt == null) { |
61 |
this.logout(); |
|
62 |
return "falure"; |
|
63 |
} |
|
|
28
by Gustav Hartvigsson
* fixed compile errors. |
64 |
if (stnt.getPwd() != this.pw_hash) { |
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
65 |
this.logout(); |
66 |
return "falure"; |
|
67 |
} |
|
68 |
this.user_type = UserTypeEnum.STUDENT; |
|
69 |
this.is_logged_in = true; |
|
70 |
this.pw_hash = null; |
|
71 |
return "success"; |
|
|
21
by Gustav Hartvigsson
* Started work on the login bean... I have no Ida what I am doing. |
72 |
} |
73 |
||
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
74 |
public String |
|
21
by Gustav Hartvigsson
* Started work on the login bean... I have no Ida what I am doing. |
75 |
staffLogin () { |
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
76 |
if (this.is_logged_in) { |
77 |
return "success"; |
|
78 |
} |
|
|
28
by Gustav Hartvigsson
* fixed compile errors. |
79 |
Staff stf = em.find(Staff.class, this.user_name); |
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
80 |
if (stf == null) { |
81 |
this.logout(); |
|
82 |
return "falure"; |
|
83 |
} |
|
|
28
by Gustav Hartvigsson
* fixed compile errors. |
84 |
if (stf.getPwd() != this.pw_hash) { |
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
85 |
this.logout(); |
86 |
return "falure"; |
|
87 |
} |
|
|
27
by Gustav Hartvigsson
* changed DB -> db |
88 |
this.user_type = UserTypeEnum.STAFF; |
|
25
by Gustav Hartvigsson
* Started implementing the Login functionality |
89 |
this.is_logged_in = true; |
90 |
this.pw_hash = null; |
|
91 |
return "success"; |
|
|
21
by Gustav Hartvigsson
* Started work on the login bean... I have no Ida what I am doing. |
92 |
} |
93 |
||
94 |
public void |
|
95 |
logout () { |
|
96 |
this.user_name = null; |
|
97 |
this.user_type = UserTypeEnum.NONE; |
|
98 |
this.is_logged_in = false; |
|
99 |
this.pw_hash = null; |
|
100 |
} |
|
101 |
||
|
15.1.7
by Gustav Hartvigsson
* added a few things that will help with development |
102 |
}
|