/[H9]/trunk/tntnet/dynamic/login.ecpp
ViewVC logotype

Diff of /trunk/tntnet/dynamic/login.ecpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 80 by torben, Wed Nov 28 14:27:51 2007 UTC revision 195 by torben, Sat Dec 8 16:47:03 2007 UTC
# Line 31  function encryptText() { Line 31  function encryptText() {
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("Refresh", "0; url=/dynamic/index");  
59                    reply.setHeader("Location", "index");
60                    return HTTP_MOVED_TEMPORARILY; //code 302
61          }          }
62          else          else
63          {          {
# Line 65  if (post_username.size() > 0 || post_pas Line 68  if (post_username.size() > 0 || post_pas
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">
# Line 85  if (showForm) { Line 85  if (showForm) {
85  </table>  </table>
86  </form>  </form>
87    
 <{  
 } // end if (showForm)  
 }>  
88    
89  <&footer>  <&footer>
90  </&footer>  </&footer>

Legend:
Removed from v.80  
changed lines
  Added in v.195

  ViewVC Help
Powered by ViewVC 1.1.20