add normal user restrictions
This commit is contained in:
		
							parent
							
								
									90a76301f2
								
							
						
					
					
						commit
						49dedcd064
					
				| @ -17,7 +17,6 @@ SOURCES += \ | |||||||
|     container_window.cpp \ |     container_window.cpp \ | ||||||
|     view_install.cpp \ |     view_install.cpp \ | ||||||
|     controller_install.cpp \ |     controller_install.cpp \ | ||||||
|     controller_remove.cpp \ |  | ||||||
|     view_info.cpp \ |     view_info.cpp \ | ||||||
|     controller_info.cpp \ |     controller_info.cpp \ | ||||||
|     view_user_info.cpp \ |     view_user_info.cpp \ | ||||||
| @ -34,7 +33,6 @@ HEADERS += \ | |||||||
|     container_window.h \ |     container_window.h \ | ||||||
|     view_install.h \ |     view_install.h \ | ||||||
|     controller_install.h \ |     controller_install.h \ | ||||||
|     controller_remove.h \ |  | ||||||
|     view_info.h \ |     view_info.h \ | ||||||
|     controller_info.h \ |     controller_info.h \ | ||||||
|     view_user_info.h \ |     view_user_info.h \ | ||||||
|  | |||||||
| @ -46,11 +46,3 @@ ssize_t conexion::write_string(std::string entrada){ | |||||||
|   return write(this->fd,entrada.data(),entrada.size()); |   return write(this->fd,entrada.data(),entrada.size()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool conexion::check_pass(std::string usernem, std::string pass){ |  | ||||||
|   this->write_string(usernem); |  | ||||||
|   this->write_string(pass); |  | ||||||
|   std::string result; |  | ||||||
|   this->read_string(result,4); |  | ||||||
|   return result=="pass"; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ public: | |||||||
| 
 | 
 | ||||||
|   virtual ssize_t read_string(std::string &entrada, int size); |   virtual ssize_t read_string(std::string &entrada, int size); | ||||||
|   virtual ssize_t write_string(std::string entrada); |   virtual ssize_t write_string(std::string entrada); | ||||||
|   bool check_pass(std::string usernem, std::string pass); |  | ||||||
| protected: | protected: | ||||||
|   config_reader *config; |   config_reader *config; | ||||||
|   int fd; |   int fd; | ||||||
|  | |||||||
| @ -8,13 +8,15 @@ container_window::container_window(conexion *con, Glib::RefPtr< Gtk::Application | |||||||
|   if(this->loggin.login){ |   if(this->loggin.login){ | ||||||
|       this->cont_inst=new controller_install(&install, sesion.get()); |       this->cont_inst=new controller_install(&install, sesion.get()); | ||||||
|       this->cont_info=new controller_info(&info, sesion.get()); |       this->cont_info=new controller_info(&info, sesion.get()); | ||||||
|       this->con_uinfo=new controller_user_info(&uinfo, sesion.get(), this); |  | ||||||
|       this->app.reset(); |       this->app.reset(); | ||||||
|       this->app=Gtk::Application::create( "org.gtkmm.examples.base"); |       this->app=Gtk::Application::create( "org.gtkmm.examples.base"); | ||||||
|       this->add(this->book); |       this->add(this->book); | ||||||
|       this->book.append_page(install,"build"); |       this->book.append_page(install,"build"); | ||||||
|       this->book.append_page(this->info,"info"); |       this->book.append_page(this->info,"info"); | ||||||
|       this->book.append_page(this->uinfo,"users"); |       if(this->loggin.admin){ | ||||||
|  |           this->con_uinfo=new controller_user_info(&uinfo, sesion.get(), this); | ||||||
|  |           this->book.append_page(this->uinfo,"users"); | ||||||
|  |         } | ||||||
|       this->show_all_children(); |       this->show_all_children(); | ||||||
|       this->app->run(*this); |       this->app->run(*this); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,17 +0,0 @@ | |||||||
| #include "controller_remove.h" |  | ||||||
| 
 |  | ||||||
| controller_remove::controller_remove(view_remove *vis, session_manager *sesi) |  | ||||||
| { |  | ||||||
|   this->view=vis; |  | ||||||
|   this->session=sesi; |  | ||||||
|   this->add_controlers(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void controller_remove::add_controlers(){ |  | ||||||
|   this->view->m_button.signal_clicked().connect(sigc::mem_fun(this, |  | ||||||
|                 &controller_remove::on_button_clicked)); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void controller_remove::on_button_clicked(){ |  | ||||||
|   this->session->remove_command(this->view->entry.get_text()); |  | ||||||
| } |  | ||||||
| @ -1,18 +0,0 @@ | |||||||
| #ifndef CONTROLLER_REMOVE_H |  | ||||||
| #define CONTROLLER_REMOVE_H |  | ||||||
| 
 |  | ||||||
| #include "view_remove.h" |  | ||||||
| #include "session_manager.h" |  | ||||||
| 
 |  | ||||||
| class controller_remove |  | ||||||
| { |  | ||||||
| public: |  | ||||||
|   controller_remove(view_remove *view, session_manager *session); |  | ||||||
| private: |  | ||||||
|   view_remove *view; |  | ||||||
|   session_manager *session; |  | ||||||
|   void add_controlers(); |  | ||||||
|   void on_button_clicked(); |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| #endif // CONTROLLER_REMOVE_H
 |  | ||||||
| @ -7,7 +7,17 @@ session_manager::session_manager(conexion* con) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool session_manager::loggin(std::string username, std::string passwd){ | bool session_manager::loggin(std::string username, std::string passwd){ | ||||||
|   return this->con->check_pass(username, passwd); |   this->con->write_string(username); | ||||||
|  |   this->con->write_string(passwd); | ||||||
|  |   std::string result; | ||||||
|  |   this->con->read_string(result,4); | ||||||
|  |   return result=="pass"; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool session_manager::admin(){ | ||||||
|  |   std::string result; | ||||||
|  |   this->con->read_string(result,5); | ||||||
|  |   return result=="admin"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int session_manager::install_command(std::string package){ | int session_manager::install_command(std::string package){ | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ public: | |||||||
|   session_manager(conexion* con); |   session_manager(conexion* con); | ||||||
|   conexion* con; |   conexion* con; | ||||||
|   bool loggin(std::string username, std::string passwd); |   bool loggin(std::string username, std::string passwd); | ||||||
|  |   bool admin(); | ||||||
|   int install_command(std::string package); |   int install_command(std::string package); | ||||||
|   int remove_command(std::string package); |   int remove_command(std::string package); | ||||||
|   std::list<std::string> get_packages_info(); |   std::list<std::string> get_packages_info(); | ||||||
|  | |||||||
| @ -43,6 +43,7 @@ void view_loggin::on_button_clicked(){ | |||||||
| 
 | 
 | ||||||
|   if(sesi->loggin(user, pass)){ |   if(sesi->loggin(user, pass)){ | ||||||
|       this->login=true; |       this->login=true; | ||||||
|  |       this->admin=sesi->admin(); | ||||||
|       this->hide(); |       this->hide(); | ||||||
|     }else{ |     }else{ | ||||||
|       this->login=false; |       this->login=false; | ||||||
|  | |||||||
| @ -28,6 +28,7 @@ public: | |||||||
|   void on_button_clicked(); |   void on_button_clicked(); | ||||||
| 
 | 
 | ||||||
|   bool login; |   bool login; | ||||||
|  |   bool admin; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif // VIEW_LOGGIN_H
 | #endif // VIEW_LOGGIN_H
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user