31 |
</script> |
</script> |
32 |
|
|
33 |
<{ |
<{ |
34 |
tntdb::Connection conn; |
tntdb::Connection conn = tntdb::connectCached(dburl); |
|
|
|
|
conn = tntdb::connect(dburl); //letting exceptions flow up and to tntnet and let it display an error message |
|
35 |
|
|
36 |
|
|
37 |
std::string post_username = qparam.param("username"); |
std::string post_username = qparam.param("username"); |
38 |
std::string post_password = qparam.param("password"); |
std::string post_password = qparam.param("password"); |
|
bool showForm = true; |
|
39 |
|
|
40 |
|
|
41 |
if (post_username.size() > 0 || post_password.size() > 0) |
if (post_username.size() > 0 || post_password.size() > 0) |
42 |
{ |
{ |
43 |
|
|
44 |
std::stringstream sql; |
std::string sql; |
45 |
sql << "SELECT realname,useradmin FROM users WHERE username = '" << post_username << "' AND "; |
sql += "SELECT realname,useradmin FROM users WHERE username = :username AND "; |
46 |
sql << "password = '" << post_password << "' AND enabled=true"; |
sql += "password = :password AND enabled=true"; |
47 |
|
|
48 |
|
tntdb::Statement st = conn.prepare(sql); |
49 |
|
st.setString("username", post_username).setString("password", post_password); |
50 |
|
|
51 |
|
tntdb::Result res = st.select(); |
52 |
|
|
|
tntdb::Result res = conn.select(sql.str()); |
|
53 |
if (res.size() >0) |
if (res.size() >0) |
54 |
{ |
{ |
55 |
tntdb::Row row = res[0]; |
tntdb::Row row = res[0]; |
56 |
userName = post_username; |
userName = post_username; |
57 |
isAdmin = row.getBool(1); |
isAdmin = row.getBool(1); |
58 |
reply.setHeader("Location", "/dynamic/index"); |
|
59 |
reply.setHeader("Refresh", "0;/dynamic/index"); |
reply.setHeader("Location", "index"); |
60 |
|
return HTTP_MOVED_TEMPORARILY; //code 302 |
61 |
} |
} |
62 |
else |
else |
63 |
{ |
{ |
68 |
|
|
69 |
|
|
70 |
|
|
|
<{ |
|
|
if (showForm) { |
|
|
}> |
|
71 |
|
|
72 |
<form method="post" action="login" name="loginform" onsubmit="encryptText()"> |
<form method="post" action="login" name="loginform" onsubmit="encryptText()"> |
73 |
<table border="0"> |
<table border="0"> |
85 |
</table> |
</table> |
86 |
</form> |
</form> |
87 |
|
|
|
<{ |
|
|
} // end if (showForm) |
|
|
}> |
|
88 |
|
|
89 |
<&footer> |
<&footer> |
90 |
</&footer> |
</&footer> |