From 593593eeecf2652c71df7a3d9c7706c8b6b089a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Piskorski?= Date: Sat, 19 Dec 2020 23:13:44 +0100 Subject: [PATCH] TAK-58 SpringBoot --- app/.Rhistory | 512 ------------------ app/app.R | 16 +- app/login_module.R | 58 +- app/profil_module.R | 14 +- app/register_module.R | 56 +- app/www/style.css | 5 + backend/.idea/compiler.xml | 23 + .../libraries/Maven__antlr_antlr_2_7_7.xml | 13 + ...__ch_qos_logback_logback_classic_1_2_3.xml | 13 + ...ven__ch_qos_logback_logback_core_1_2_3.xml | 13 + .../Maven__com_fasterxml_classmate_1_3_4.xml | 13 + ...jackson_core_jackson_annotations_2_9_0.xml | 13 + ...terxml_jackson_core_jackson_core_2_9_4.xml | 13 + ...ml_jackson_core_jackson_databind_2_9_4.xml | 13 + ...ataformat_jackson_dataformat_xml_2_9_4.xml | 13 + ...n_datatype_jackson_datatype_jdk8_2_9_4.xml | 13 + ...datatype_jackson_datatype_jsr310_2_9_4.xml | 13 + ..._jackson_module_jaxb_annotations_2_9_4.xml | 13 + ...e_jackson_module_parameter_names_2_9_4.xml | 13 + ...fasterxml_woodstox_woodstox_core_5_0_3.xml | 13 + ...n__com_jayway_jsonpath_json_path_2_4_0.xml | 13 + ...ogle_android_json_0_0_20131108_vaadin1.xml | 13 + .../Maven__com_zaxxer_HikariCP_2_7_8.xml | 13 + .../libraries/Maven__dom4j_dom4j_1_6_1.xml | 13 + ..._annotation_javax_annotation_api_1_3_2.xml | 13 + ..._transaction_javax_transaction_api_1_2.xml | 13 + ..._validation_validation_api_2_0_1_Final.xml | 13 + .../Maven__javax_xml_bind_jaxb_api_2_3_0.xml | 13 + .../libraries/Maven__junit_junit_4_12.xml | 13 + ...ven__mysql_mysql_connector_java_5_1_45.xml | 13 + ...Maven__net_bytebuddy_byte_buddy_1_7_10.xml | 13 + ..._net_bytebuddy_byte_buddy_agent_1_7_10.xml | 13 + ...Maven__net_minidev_accessors_smart_1_2.xml | 13 + .../Maven__net_minidev_json_smart_2_3.xml | 13 + ..._apache_logging_log4j_log4j_api_2_10_0.xml | 13 + ...he_logging_log4j_log4j_to_slf4j_2_10_0.xml | 13 + ..._tomcat_embed_tomcat_embed_core_8_5_28.xml | 13 + ...he_tomcat_embed_tomcat_embed_el_8_5_28.xml | 13 + ...at_embed_tomcat_embed_websocket_8_5_28.xml | 13 + ...aven__org_aspectj_aspectjweaver_1_8_13.xml | 13 + .../Maven__org_assertj_assertj_core_3_9_1.xml | 13 + ..._org_codehaus_woodstox_stax2_api_3_1_4.xml | 13 + .../Maven__org_hamcrest_hamcrest_core_1_3.xml | 13 + ...ven__org_hamcrest_hamcrest_library_1_3.xml | 13 + ...ernate_commons_annotations_5_0_1_Final.xml | 13 + ..._hibernate_hibernate_core_5_2_14_Final.xml | 13 + ...ence_hibernate_jpa_2_1_api_1_0_0_Final.xml | 13 + ...idator_hibernate_validator_6_0_7_Final.xml | 13 + ...ven__org_javassist_javassist_3_22_0_GA.xml | 13 + .../Maven__org_jboss_jandex_2_0_3_Final.xml | 13 + ...boss_logging_jboss_logging_3_3_2_Final.xml | 13 + ...Maven__org_mockito_mockito_core_2_15_0.xml | 13 + .../Maven__org_objenesis_objenesis_2_6.xml | 13 + .../Maven__org_ow2_asm_asm_5_0_4.xml | 13 + ...aven__org_skyscreamer_jsonassert_1_5_0.xml | 13 + .../Maven__org_slf4j_jul_to_slf4j_1_7_25.xml | 13 + .../Maven__org_slf4j_slf4j_api_1_7_25.xml | 13 + ...amework_boot_spring_boot_2_0_0_RELEASE.xml | 13 + ...pring_boot_autoconfigure_2_0_0_RELEASE.xml | 13 + ...oot_spring_boot_devtools_2_0_0_RELEASE.xml | 13 + ...boot_spring_boot_starter_2_0_0_RELEASE.xml | 13 + ..._spring_boot_starter_aop_2_0_0_RELEASE.xml | 13 + ...ng_boot_starter_data_jpa_2_0_0_RELEASE.xml | 13 + ...spring_boot_starter_jdbc_2_0_0_RELEASE.xml | 13 + ...spring_boot_starter_json_2_0_0_RELEASE.xml | 13 + ...ing_boot_starter_logging_2_0_0_RELEASE.xml | 13 + ...spring_boot_starter_test_2_0_0_RELEASE.xml | 13 + ...ring_boot_starter_tomcat_2_0_0_RELEASE.xml | 13 + ..._spring_boot_starter_web_2_0_0_RELEASE.xml | 13 + ...rk_boot_spring_boot_test_2_0_0_RELEASE.xml | 13 + ..._boot_test_autoconfigure_2_0_0_RELEASE.xml | 13 + ...data_spring_data_commons_2_0_5_RELEASE.xml | 13 + ...ork_data_spring_data_jpa_2_0_5_RELEASE.xml | 13 + ...ringframework_spring_aop_5_0_4_RELEASE.xml | 13 + ...framework_spring_aspects_5_0_4_RELEASE.xml | 13 + ...ngframework_spring_beans_5_0_4_RELEASE.xml | 13 + ...framework_spring_context_5_0_4_RELEASE.xml | 13 + ...ingframework_spring_core_5_0_4_RELEASE.xml | 13 + ...mework_spring_expression_5_0_4_RELEASE.xml | 13 + ...ringframework_spring_jcl_5_0_4_RELEASE.xml | 13 + ...ingframework_spring_jdbc_5_0_4_RELEASE.xml | 13 + ...ringframework_spring_orm_5_0_4_RELEASE.xml | 13 + ...ingframework_spring_test_5_0_4_RELEASE.xml | 13 + ...pringframework_spring_tx_5_0_4_RELEASE.xml | 13 + ...ringframework_spring_web_5_0_4_RELEASE.xml | 13 + ...gframework_spring_webmvc_5_0_4_RELEASE.xml | 13 + .../Maven__org_xmlunit_xmlunit_core_2_5_1.xml | 13 + .../Maven__org_yaml_snakeyaml_1_19.xml | 13 + backend/.idea/vcs.xml | 7 + backend/.idea/workspace.xml | 224 ++++++++ backend/README.md | 3 + backend/pom.xml | 112 ++++ backend/src/main/database/dump.sql | 181 +++++++ .../src/main/java/project/DTO/RoleDTO.java | 22 + .../src/main/java/project/DTO/UserDTO.java | 82 +++ .../src/main/java/project/TakeCareApp.java | 25 + .../config/JwtAuthenticationEntryPoint.java | 22 + .../config/JwtAuthenticationFilter.java | 79 +++ .../project/config/SecurityConfiguration.java | 111 ++++ .../main/java/project/config/TokenHelper.java | 106 ++++ .../controllers/AuthenticationController.java | 87 +++ .../ControllersExceptionHandler.java | 22 + .../project/controllers/UserController.java | 174 ++++++ .../java/project/model/CustomUserDetails.java | 53 ++ backend/src/main/java/project/model/Role.java | 45 ++ backend/src/main/java/project/model/User.java | 108 ++++ .../project/repositories/RoleRepository.java | 16 + .../project/repositories/UserRepository.java | 19 + .../java/project/services/GeneratorDTO.java | 22 + .../java/project/services/RoleService.java | 9 + .../project/services/RoleServiceImpl.java | 24 + .../java/project/services/UserService.java | 20 + .../project/services/UserServiceImpl.java | 81 +++ .../src/main/resources/application.properties | 26 + 114 files changed, 2836 insertions(+), 581 deletions(-) delete mode 100644 app/.Rhistory create mode 100644 backend/.idea/compiler.xml create mode 100644 backend/.idea/libraries/Maven__antlr_antlr_2_7_7.xml create mode 100644 backend/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml create mode 100644 backend/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_4.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_4.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_xml_2_9_4.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_4.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_4.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_jaxb_annotations_2_9_4.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_4.xml create mode 100644 backend/.idea/libraries/Maven__com_fasterxml_woodstox_woodstox_core_5_0_3.xml create mode 100644 backend/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml create mode 100644 backend/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml create mode 100644 backend/.idea/libraries/Maven__com_zaxxer_HikariCP_2_7_8.xml create mode 100644 backend/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml create mode 100644 backend/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml create mode 100644 backend/.idea/libraries/Maven__javax_transaction_javax_transaction_api_1_2.xml create mode 100644 backend/.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml create mode 100644 backend/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_0.xml create mode 100644 backend/.idea/libraries/Maven__junit_junit_4_12.xml create mode 100644 backend/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_45.xml create mode 100644 backend/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_7_10.xml create mode 100644 backend/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_7_10.xml create mode 100644 backend/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml create mode 100644 backend/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml create mode 100644 backend/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml create mode 100644 backend/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml create mode 100644 backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_28.xml create mode 100644 backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_28.xml create mode 100644 backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_28.xml create mode 100644 backend/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_13.xml create mode 100644 backend/.idea/libraries/Maven__org_assertj_assertj_core_3_9_1.xml create mode 100644 backend/.idea/libraries/Maven__org_codehaus_woodstox_stax2_api_3_1_4.xml create mode 100644 backend/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml create mode 100644 backend/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml create mode 100644 backend/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_0_1_Final.xml create mode 100644 backend/.idea/libraries/Maven__org_hibernate_hibernate_core_5_2_14_Final.xml create mode 100644 backend/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_1_api_1_0_0_Final.xml create mode 100644 backend/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_7_Final.xml create mode 100644 backend/.idea/libraries/Maven__org_javassist_javassist_3_22_0_GA.xml create mode 100644 backend/.idea/libraries/Maven__org_jboss_jandex_2_0_3_Final.xml create mode 100644 backend/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml create mode 100644 backend/.idea/libraries/Maven__org_mockito_mockito_core_2_15_0.xml create mode 100644 backend/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml create mode 100644 backend/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml create mode 100644 backend/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml create mode 100644 backend/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml create mode 100644 backend/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_devtools_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_0_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_0_5_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_0_5_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_aop_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_aspects_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_beans_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_context_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_core_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_expression_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_orm_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_test_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_tx_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_web_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_4_RELEASE.xml create mode 100644 backend/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_5_1.xml create mode 100644 backend/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml create mode 100644 backend/.idea/vcs.xml create mode 100644 backend/.idea/workspace.xml create mode 100644 backend/README.md create mode 100644 backend/pom.xml create mode 100644 backend/src/main/database/dump.sql create mode 100644 backend/src/main/java/project/DTO/RoleDTO.java create mode 100644 backend/src/main/java/project/DTO/UserDTO.java create mode 100644 backend/src/main/java/project/TakeCareApp.java create mode 100644 backend/src/main/java/project/config/JwtAuthenticationEntryPoint.java create mode 100644 backend/src/main/java/project/config/JwtAuthenticationFilter.java create mode 100644 backend/src/main/java/project/config/SecurityConfiguration.java create mode 100644 backend/src/main/java/project/config/TokenHelper.java create mode 100644 backend/src/main/java/project/controllers/AuthenticationController.java create mode 100644 backend/src/main/java/project/controllers/ControllersExceptionHandler.java create mode 100644 backend/src/main/java/project/controllers/UserController.java create mode 100644 backend/src/main/java/project/model/CustomUserDetails.java create mode 100644 backend/src/main/java/project/model/Role.java create mode 100644 backend/src/main/java/project/model/User.java create mode 100644 backend/src/main/java/project/repositories/RoleRepository.java create mode 100644 backend/src/main/java/project/repositories/UserRepository.java create mode 100644 backend/src/main/java/project/services/GeneratorDTO.java create mode 100644 backend/src/main/java/project/services/RoleService.java create mode 100644 backend/src/main/java/project/services/RoleServiceImpl.java create mode 100644 backend/src/main/java/project/services/UserService.java create mode 100644 backend/src/main/java/project/services/UserServiceImpl.java create mode 100644 backend/src/main/resources/application.properties diff --git a/app/.Rhistory b/app/.Rhistory deleted file mode 100644 index 71d6d15..0000000 --- a/app/.Rhistory +++ /dev/null @@ -1,512 +0,0 @@ -y<-c("Eisenhower (34)", "Kennedy (35)", "Johnson (36)" ,"Nixon (37)" ,"Ford (38)", "Carter (39)","Reagan (40)","Bush (41)","Clinton (42)","Bush (43)","Obama (44)") -presidential %>% -mutate(id = 33 + row_number()) %>% -ggplot(aes(start, id, colour = party)) + -geom_point() + -geom_segment(aes(xend = end, yend = id)) + -scale_colour_manual(values = c(Republican = "red", Democratic = "blue"))+ -labs(x = "", -y = "" -)+ -scale_y_continuous(labels=y,breaks = x)+ -scale_x_date(date_breaks = "4 years",date_labels = "'%y") -#3. -x<-seq(by=1,(34),(44)) -y<-c("Eisenhower (34)", "Kennedy (35)", "Johnson (36)" ,"Nixon (37)" ,"Ford (38)", "Carter (39)","Reagan (40)","Bush (41)","Clinton (42)","Bush (43)","Obama (44)") -presidential %>% -mutate(id = 33 + row_number()) %>% -ggplot(aes(start, id, colour = party)) + -geom_point() + -geom_segment(aes(xend = end, yend = id)) + -scale_colour_manual(values = c(Republican = "red", Democratic = "blue"))+ -labs(x = "", -y = "" -)+ -scale_y_continuous(labels=y,breaks = x)+ -scale_x_date(date_breaks = "4 years",date_labels = "'%y") -#5.3.1 -#1. -label <- tibble( -x=c(-Inf,-Inf,Inf,Inf), -y=c(-Inf, Inf,-Inf,Inf), -label=c("x","x","x","x"), -hjust=c(0,0,1,1), -vjust=c(0,1.0,0,1) -) -ggplot(mpg, aes(displ, hwy)) + -geom_point() + -geom_text(data=label,aes(x=c(-Inf,-Inf,Inf,Inf),y=c(-Inf, Inf,-Inf,Inf),hjust=c(0,0,1,1), -vjust=c(0,1.0,0,1),label=c("x","x","x","x"))) -#3. -#rozne etykiety na kazdym panelu -label <- tibble( -label = c("x","xx","xxx"), -drv = c("4", "f","r") -) -ggplot(data = mpg) + -geom_point(mapping = aes(x = displ, y = hwy)) + -facet_wrap(~ drv, nrow = 2)+ -geom_text(data = label, aes(x = 10, y = 10, label = label)) -#etykieta do pojedynczego panelu -label <- tibble( -label = c("x"), -drv = c("4") -) -ggplot(data = mpg) + -geom_point(mapping = aes(x = displ, y = hwy)) + -facet_wrap(~ drv, nrow = 2)+ -geom_text(data = label, aes(x = 10, y = 10, label = label)) -#3. -#Gdy damy -label <- tibble( -label = "x" -) -ggplot(data = mpg) + -geom_point(mapping = aes(x = displ, y = hwy)) + -facet_wrap(~ drv, nrow = 2)+ -geom_text(data = label, aes(x = 10, y = 10, label = label)) -strzalka=arrow(angle = 10, length = unit(0.5, "inches"), -ends = "last", type = "open") -ggplot(mpg, aes(displ, hwy)) + -geom_point() + -geom_segment(x=0,y=0,arrow=strzalka,xend=5,yend=40) -strzalka=arrow(angle = 80, length = unit(0.1, "inches"), -ends = "both", type = "closed") -ggplot(mpg, aes(displ, hwy)) + -geom_point() + -geom_segment(x=0,y=0,arrow=strzalka,xend=5,yend=40) -strzalka=arrow(angle = 20, length = unit(10, "inches"), -ends = "last", type = "closed") -ggplot(mpg, aes(displ, hwy)) + -geom_point() + -geom_segment(x=0,y=0,arrow=strzalka,xend=5,yend=40) -#3. -x<-seq(by=1,(34),(44)) -y<-c("Eisenhower (34)", "Kennedy (35)", "Johnson (36)" ,"Nixon (37)" ,"Ford (38)", "Carter (39)","Reagan (40)","Bush (41)","Clinton (42)","Bush (43)","Obama (44)") -presidential %>% -mutate(id = 33 + row_number()) %>% -ggplot(aes(start, id, colour = party)) + -geom_point() + -geom_segment(aes(xend = end, yend = id)) + -scale_colour_manual(values = c(Republican = "red", Democratic = "blue"))+ -labs(x = "", -y = "" -)+ -scale_y_continuous(labels=y,breaks = x)+ -scale_x_date(date_breaks = "4 years",date_labels = "'%y") -library(shiny); runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -library(shiny) -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('xd') -runApp('xd') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('~/Desktop/TPD/8/8.10.R') -runApp('~/Desktop/TPD/8/8.10.R') -runApp('~/Desktop/TPD/8/8.10.R') -runApp('~/Desktop/TPD/8/8.10.R') -runApp('~/Desktop/TPD/8/8.10.R') -runApp('~/Desktop/TPD/8/8.3.6.R') -runApp('~/Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('~/Desktop/TPD/8/8.10.R') -runApp('~/Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -input$slider1 -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -?double() -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -library(ggplot2) -x=seq(by=1,-8,8) -x -x=seq(by=1,-8,8) -runApp('Desktop/TPD/8/8.10.R') -d -x=seq(by=1,-8,8) -y=1/(1+exp(-x)) -x=seq(by=1,-8,8) -y=1/(1+exp(-x)) -d=data.frame(x,y) -View(d) -View(d) -plot(x,y) -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -?geom_abline() -x=seq(by=1,-8,8) -y=1/(1+exp(-x)) -d=data.frame(x,y) -ggplot(data=d,aes(x=x,y=y))+ -geom_line()+ -geom_abline() -labs(x="premises",y="prediction") -ggplot(data=d,aes(x=x,y=y))+ -geom_line()+ -geom_point(aes(x=1,y=2))+ -labs(x="premises",y="prediction") -ggplot(data=d,aes(x=x,y=y))+ -geom_line()+ -geom_point(aes(x=1,y=2),color="red")+ -labs(x="premises",y="prediction") -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -ggplot(data=d,aes(x=x,y=y))+ -geom_line()+ -geom_point(aes(x=z,y=1/(1+exp(-z))),color="red")+ -labs(x="premises",y="prediction")+ -geom_line(aes(x=0,y=0.1),linetype = "dashed") -z=-5.3718+0.0354*as.numeric(input$slider1)+1.6159*as.numeric(input$select1)+1.1768*as.numeric(input$select2)+0.0697*as.numeric(input$slider2)+0.9586*as.numeric(input$select3)-2.9486*as.numeric(input$select4) -x=seq(by=1,-8,8) -y=1/(1+exp(-x)) -d=data.frame(x,y) -ggplot(data=d,aes(x=x,y=y))+ -geom_line()+ -geom_point(aes(x=z,y=1/(1+exp(-z))),color="red")+ -labs(x="premises",y="prediction")+ -geom_line(aes(x=0,y=0.1),linetype = "dashed") -z=-5.3718+0.0354*as.numeric(input$slider1)+1.6159*as.numeric(input$select1)+1.1768*as.numeric(input$select2)+0.0697*as.numeric(input$slider2)+0.9586*as.numeric(input$select3)-2.9486*as.numeric(input$select4) -z=0.019 -x=seq(by=1,-8,8) -y=1/(1+exp(-x)) -d=data.frame(x,y) -ggplot(data=d,aes(x=x,y=y))+ -geom_line()+ -geom_point(aes(x=z,y=1/(1+exp(-z))),color="red")+ -labs(x="premises",y="prediction")+ -geom_line(aes(x=0,y=0.1),linetype = "dashed") -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -?geom_line() -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.10.R') -library(shiny); runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('dddd') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('j:/Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.5.5.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.3.6.R') -library(ggplot2) -library(dplyr) -smaller <- diamonds %>% -filter(carat <= 2.5) -```{r} -# Zadanie 4.4.8.1 -ggplot(data = diamonds) + -geom_line(mapping = aes(x = carat, y = color, color = color)) + -facet_grid(clarity ~ cut ) -bigger <- diamonds %>% -filter(carat > 2.5) -knitr::kable( -bigger[1:20, 1:5], -caption = "20 najwiekszych diamentow i ich cechy." -) -version -shiny::runApp('j:/Desktop/TakeCareApp/app') -install.packages("shiny.router") -runApp('j:/Desktop/TakeCareApp/app') -runApp('j:/Desktop/TakeCareApp/app') -runApp('j:/Desktop/TakeCareApp/app') -runApp('j:/Desktop/TakeCareApp/app') -runApp('j:/Desktop/TakeCareApp/app') -runApp('j:/Desktop/TakeCareApp/app') -library(tidyverse) -#3. -x<-seq(by=1,(34),(44)) -y<-c("Eisenhower (34)", "Kennedy (35)", "Johnson (36)" ,"Nixon (37)" ,"Ford (38)", "Carter (39)","Reagan (40)","Bush (41)","Clinton (42)","Bush (43)","Obama (44)") -presidential %>% -mutate(id = 33 + row_number()) %>% -ggplot(aes(start, id, colour = party)) + -geom_point() + -geom_segment(aes(xend = end, yend = id)) + -scale_colour_manual(values = c(Republican = "red", Democratic = "blue"))+ -labs(x = "", -y = "" -)+ -scale_y_continuous(labels=y,breaks = x)+ -scale_x_date(date_breaks = "4 years",date_labels = "'%y") -#4. -ggplot(diamonds, aes(carat, price)) + -geom_point(aes(colour = cut), alpha = 1/20)+ -theme(legend.position = "bottom") + -guides(colour = guide_legend(nrow = 1, override.aes = list(alpha=1))) -#3. -x<-seq(by=1,(34),(44)) -y<-c("Eisenhower (34)", "Kennedy (35)", "Johnson (36)" ,"Nixon (37)" ,"Ford (38)", "Carter (39)","Reagan (40)","Bush (41)","Clinton (42)","Bush (43)","Obama (44)") -presidential %>% -mutate(id = 33 + row_number()) %>% -ggplot(aes(start, id, colour = party)) + -geom_point() + -geom_segment(aes(xend = end, yend = id)) + -scale_colour_manual(values = c(Republican = "red", Democratic = "blue"))+ -labs(x = "", -y = "" -)+ -scale_y_continuous(labels=y,breaks = x)+ -scale_x_date(date_breaks = "4 years",date_labels = "'%y") -#5.4.4 -#1. -df <- tibble( -x = rnorm(10000), -y = rnorm(10000) -) -ggplot(df, aes(x, y)) + -geom_hex() + -scale_colour_gradient(low = "white", high = "red") + -coord_fixed() -#2. -?scale_x_log10() -#Pierwszy argument w kazdej skali to name. a w labs pierwszym argumentem jest lista nowych par nazwa-wartość. Nazwa powinna być estetyką. -#W skalach mozna ustawic nazwe osi tak jak za pomoca funkcji labs(). Za pomoca labs mozemy zmieniac wiecej etykiet niz za pomoca skal. -#scale_y_continuous(name="xd",labels=y,breaks = x) -#labs(x="xd",y="p") -?labs() -#3. -x<-seq(by=1,(34),(44)) -y<-c("Eisenhower (34)", "Kennedy (35)", "Johnson (36)" ,"Nixon (37)" ,"Ford (38)", "Carter (39)","Reagan (40)","Bush (41)","Clinton (42)","Bush (43)","Obama (44)") -presidential %>% -mutate(id = 33 + row_number()) %>% -ggplot(aes(start, id, colour = party)) + -geom_point() + -geom_segment(aes(xend = end, yend = id)) + -scale_colour_manual(values = c(Republican = "red", Democratic = "blue"))+ -labs(x = "", -y = "" -)+ -scale_y_continuous(labels=y,breaks = x)+ -scale_x_date(date_breaks = "4 years",date_labels = "'%y") -library(shiny); runApp('Desktop/TPD/8/8.10.R') -runApp('Desktop/TPD/8/8.3.6.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.4.2.R') -runApp('Desktop/TPD/8/8.5.5.R') -library(shiny); runApp('j:/Desktop/TakeCareApp/app/calculations.R') -runApp('j:/Desktop/TakeCareApp/app/calculations.R') -runApp('j:/Desktop/TakeCareApp/app/calculations.R') -runApp('j:/Desktop/TakeCareApp/app/calculations.R') -runApp('j:/Desktop/TakeCareApp/app/calculations.R') -runApp('j:/Desktop/TakeCareApp/app/calculations.R') -library(shiny); runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('j:/Desktop/TakeCareApp/app/authors.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -library(shiny); runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') -runApp('Desktop/TakeCareApp/app/about.R') diff --git a/app/app.R b/app/app.R index 7d9199b..95dacc6 100644 --- a/app/app.R +++ b/app/app.R @@ -16,11 +16,19 @@ source("routing_module.R",encoding="utf-8") ui <- fluidPage( useShinyjs(), tags$head( - tags$script(src="js.cookie.js") + tags$script(src="js.cookie.js"), + + tags$script('var cookie = Cookies.get(\'token\'); + $(document).on("shiny:sessioninitialized",function(event){ + Shiny.onInputChange("token", cookie);});'), + tags$script('Shiny.addCustomMessageHandler("tokenHandler", + function(token) { + var cookie = Cookies.set(\'token\', token, { expires: 7 }); + Shiny.onInputChange("token", cookie); + + } +);') ), - # tags$script('var cookie = Cookies.get(\'token\'); - # $(document).on("shiny:sessioninitialized",function(event){ - # Shiny.onInputChange("token", cookie);});')), uiOutput("logged"), diff --git a/app/login_module.R b/app/login_module.R index 54ceba1..081ac74 100644 --- a/app/login_module.R +++ b/app/login_module.R @@ -3,6 +3,7 @@ library(magrittr) library(ggplot2) library(plotly) library(DT) +library(httr) source("connection_module.R",encoding="utf-8") @@ -12,6 +13,14 @@ loginUI <- function(id) { useShinyjs(), tags$head( tags$script(src="js.cookie.js"), + tags$script('Shiny.addCustomMessageHandler("tokenHandlerAfterLogin", + function(token) { + var cookie = Cookies.set(\'token\', token, { expires: 7 }); + Shiny.onInputChange("token", cookie); + + window.location.replace(\'/#!/profil\'); + } +);'), tags$style(HTML(" @import url('//fonts.googleapis.com/css?family=Lobster|Cabin:400,700'); @import url('//fonts.googleapis.com/css2?family=Fjalla+One'); @@ -48,20 +57,24 @@ loginServer <- function(input, output,session) { isCorrect <- eventReactive(input$loginBtn, { tmp<-data.frame(login=input$login,pass=input$pass) - number<-login(tmp) - print(number) - if(number!=0){ - shinyjs::runjs( 'Cookies.set(\'token\', \'loggedIn\', { expires: 7 }); - - var cookie = Cookies.get(\'token\'); - Shiny.onInputChange("token", cookie); - window.location.replace(\'/#!/profil\');') + + to_send = list(login = tmp$login, + password = tmp$pass) + + r<-httr::POST("http://localhost:8080/api/login",body=to_send,encode = 'json') + + if(r$status_code==200){ + + response<-(content(r)) + session$sendCustomMessage(type='tokenHandlerAfterLogin', response$token) + + TRUE - - - - }else{ + } + + + else{ FALSE } @@ -78,26 +91,7 @@ loginServer <- function(input, output,session) { }) - # observeEvent(input$loginBtn,{ - # tmp<-data.frame(login=input$login,pass=input$pass) - # number<-login(tmp) - # print(number) - # if(number!=0){ - # shinyjs::runjs( 'Cookies.set(\'token\', \'loggedIn\', { expires: 7 }); - # - # var cookie = Cookies.get(\'token\'); - # Shiny.onInputChange("token", cookie); - # window.location.replace(\'/#!/profil\');') - # - # - # - # }else{ - # - # } - # - # - # }) - + observe({ if(((session$clientData)$url_hash=="#!/login") & (!is.null(input$token) & length(input$token)>0 )){ diff --git a/app/profil_module.R b/app/profil_module.R index f6e2da2..bc5671a 100644 --- a/app/profil_module.R +++ b/app/profil_module.R @@ -43,11 +43,17 @@ profilServer <- function(input, output,session) { observe({ - if(((session$clientData)$url_hash=="#!/profil") & (is.null(input$token) | length(input$token)<=0 )){ + if(( (session$clientData)$url_hash=="#!/profil")){ - print("dziala") - shinyjs::runjs('window.location.replace(\'/#!/home\');') - } + + + if( (is.null(input$token) | length(input$token)<=0 )){ + + shinyjs::runjs('window.location.replace(\'/#!/home\');') + } + } + + }) diff --git a/app/register_module.R b/app/register_module.R index 04a0d0c..6928565 100644 --- a/app/register_module.R +++ b/app/register_module.R @@ -3,6 +3,8 @@ library(magrittr) library(ggplot2) library(plotly) library(DT) +library(rjson) + connection <-source("connection_module.R",encoding="utf-8") registerUI <- function(id) { ns <- NS(id) @@ -52,10 +54,10 @@ registerServer <- function(input, output,session) { result$name<-input$name result$surname<-input$surname result$mail<-input$mail - result$age<-input$age + result$datebirth<-input$age result$gender<-input$gender - result$username<-input$username - result$haslo<-input$haslo + result$login<-input$username + result$password<-input$haslo result$permission<-input$permission @@ -63,17 +65,34 @@ registerServer <- function(input, output,session) { grepl("^[A-Z][a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż]{2,20}$",result$surname), grepl("^[a-z]+[0-9]*@([a-z]{2,10}\\.)+[a-z]{2,5}$",result$mail), grepl("^([a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż]+[0-9\\-\\_]*){5,20}$",result$username), - grepl("^([a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż]{5,}[0-9]{5,}[a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż0-9]*)+$",result$haslo)) + grepl("^([a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż]{5,}[0-9]{5,}[a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż0-9]*)+$",result$password)) if(all(reg) & all(result$permission==c(1,2))){ - status$status = register(result) - status$first = FALSE + # status$status = register(result) + + status$first = FALSE + + to_send = list(name = result$name, + surname = result$surname, + email = result$mail, + datebirth = result$datebirth, + gender = result$gender, + login = result$login, + password= result$password, + roleDTO= "IND") + r<-httr::POST("http://localhost:8080/api/register",body=to_send,encode = 'json') + print(content(r, "text")) + if (r$status_code==200){ + status$status = TRUE + }else{ + status$status = FALSE + } }else{ status$status = FALSE } - + status$status @@ -158,28 +177,7 @@ registerServer <- function(input, output,session) { }else{ p("Uzytkownik istnieje lub wprowadzono bledne dane",style="color:yellow;text-align:center;") } - # i<-(input$loginBtn) - # if (runif(1, -1.0, 1.0)>0){ - - # }else{ - - # } - - - # result <- data.frame(name=input$name,surname=input$surname,mail=input$mail,age=input$age,gender=input$gender,login=input$login,pass=input$pass) - - # if(is.null(correct$status)){ - # p("NULL",style="color:yellow") - # }else - # status<-correct() - # if(status==FALSE){ - # p("Bład: Podaj poprawne dane",style="color:yellow") - # }else if(status==TRUE){ - # p("OK",style="color:yellow") - # }else{ - # print(status) - # p("OK",style="color:yellow") - # } + }) diff --git a/app/www/style.css b/app/www/style.css index f7a0288..a69da1f 100644 --- a/app/www/style.css +++ b/app/www/style.css @@ -101,6 +101,11 @@ background-color:#00A896; #font-family: Fjalla One; } +.navbar-default .navbar-nav > li:hover{ + cursor:pointer; + background-color: #008375; +} + .navbar-default .navbar-nav > li > a{ color: #FFFFFF !important; font-family: Fjalla One; diff --git a/backend/.idea/compiler.xml b/backend/.idea/compiler.xml new file mode 100644 index 0000000..eff75d1 --- /dev/null +++ b/backend/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__antlr_antlr_2_7_7.xml b/backend/.idea/libraries/Maven__antlr_antlr_2_7_7.xml new file mode 100644 index 0000000..b8d93d8 --- /dev/null +++ b/backend/.idea/libraries/Maven__antlr_antlr_2_7_7.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml b/backend/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml new file mode 100644 index 0000000..6fec8f4 --- /dev/null +++ b/backend/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml b/backend/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml new file mode 100644 index 0000000..9eb8596 --- /dev/null +++ b/backend/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml b/backend/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml new file mode 100644 index 0000000..33c30b4 --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml b/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml new file mode 100644 index 0000000..06441f4 --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_4.xml b/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_4.xml new file mode 100644 index 0000000..5de0355 --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_4.xml b/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_4.xml new file mode 100644 index 0000000..398994e --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_xml_2_9_4.xml b/backend/.idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_xml_2_9_4.xml new file mode 100644 index 0000000..77665b9 --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_xml_2_9_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_4.xml b/backend/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_4.xml new file mode 100644 index 0000000..4793ed1 --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_4.xml b/backend/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_4.xml new file mode 100644 index 0000000..d84e40f --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_jaxb_annotations_2_9_4.xml b/backend/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_jaxb_annotations_2_9_4.xml new file mode 100644 index 0000000..cafc86e --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_jaxb_annotations_2_9_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_4.xml b/backend/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_4.xml new file mode 100644 index 0000000..ee544ba --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_fasterxml_woodstox_woodstox_core_5_0_3.xml b/backend/.idea/libraries/Maven__com_fasterxml_woodstox_woodstox_core_5_0_3.xml new file mode 100644 index 0000000..c08dcae --- /dev/null +++ b/backend/.idea/libraries/Maven__com_fasterxml_woodstox_woodstox_core_5_0_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml b/backend/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml new file mode 100644 index 0000000..f19f6eb --- /dev/null +++ b/backend/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml b/backend/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml new file mode 100644 index 0000000..b8581a6 --- /dev/null +++ b/backend/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__com_zaxxer_HikariCP_2_7_8.xml b/backend/.idea/libraries/Maven__com_zaxxer_HikariCP_2_7_8.xml new file mode 100644 index 0000000..848c412 --- /dev/null +++ b/backend/.idea/libraries/Maven__com_zaxxer_HikariCP_2_7_8.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml b/backend/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml new file mode 100644 index 0000000..14681ee --- /dev/null +++ b/backend/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml b/backend/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml new file mode 100644 index 0000000..e74f3ab --- /dev/null +++ b/backend/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__javax_transaction_javax_transaction_api_1_2.xml b/backend/.idea/libraries/Maven__javax_transaction_javax_transaction_api_1_2.xml new file mode 100644 index 0000000..5f032d2 --- /dev/null +++ b/backend/.idea/libraries/Maven__javax_transaction_javax_transaction_api_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml b/backend/.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml new file mode 100644 index 0000000..6978c0b --- /dev/null +++ b/backend/.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_0.xml b/backend/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_0.xml new file mode 100644 index 0000000..59ff9c2 --- /dev/null +++ b/backend/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__junit_junit_4_12.xml b/backend/.idea/libraries/Maven__junit_junit_4_12.xml new file mode 100644 index 0000000..d411041 --- /dev/null +++ b/backend/.idea/libraries/Maven__junit_junit_4_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_45.xml b/backend/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_45.xml new file mode 100644 index 0000000..8280cea --- /dev/null +++ b/backend/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_45.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_7_10.xml b/backend/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_7_10.xml new file mode 100644 index 0000000..7b90f25 --- /dev/null +++ b/backend/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_7_10.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_7_10.xml b/backend/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_7_10.xml new file mode 100644 index 0000000..c9e49ad --- /dev/null +++ b/backend/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_7_10.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml b/backend/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml new file mode 100644 index 0000000..b3d3858 --- /dev/null +++ b/backend/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml b/backend/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml new file mode 100644 index 0000000..1083023 --- /dev/null +++ b/backend/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml b/backend/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml new file mode 100644 index 0000000..cbe5ca7 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml b/backend/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml new file mode 100644 index 0000000..1407c58 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_28.xml b/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_28.xml new file mode 100644 index 0000000..c83f72e --- /dev/null +++ b/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_28.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_28.xml b/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_28.xml new file mode 100644 index 0000000..a90b7bb --- /dev/null +++ b/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_28.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_28.xml b/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_28.xml new file mode 100644 index 0000000..66bd03f --- /dev/null +++ b/backend/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_28.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_13.xml b/backend/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_13.xml new file mode 100644 index 0000000..d46e30a --- /dev/null +++ b/backend/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_13.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_assertj_assertj_core_3_9_1.xml b/backend/.idea/libraries/Maven__org_assertj_assertj_core_3_9_1.xml new file mode 100644 index 0000000..40adaaa --- /dev/null +++ b/backend/.idea/libraries/Maven__org_assertj_assertj_core_3_9_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_codehaus_woodstox_stax2_api_3_1_4.xml b/backend/.idea/libraries/Maven__org_codehaus_woodstox_stax2_api_3_1_4.xml new file mode 100644 index 0000000..b510642 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_codehaus_woodstox_stax2_api_3_1_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/backend/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..f58bbc1 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml b/backend/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml new file mode 100644 index 0000000..78dbe45 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_0_1_Final.xml b/backend/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_0_1_Final.xml new file mode 100644 index 0000000..ce34f42 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_0_1_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_hibernate_hibernate_core_5_2_14_Final.xml b/backend/.idea/libraries/Maven__org_hibernate_hibernate_core_5_2_14_Final.xml new file mode 100644 index 0000000..3a3af4f --- /dev/null +++ b/backend/.idea/libraries/Maven__org_hibernate_hibernate_core_5_2_14_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_1_api_1_0_0_Final.xml b/backend/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_1_api_1_0_0_Final.xml new file mode 100644 index 0000000..6492b2b --- /dev/null +++ b/backend/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_1_api_1_0_0_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_7_Final.xml b/backend/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_7_Final.xml new file mode 100644 index 0000000..a4f8873 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_7_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_javassist_javassist_3_22_0_GA.xml b/backend/.idea/libraries/Maven__org_javassist_javassist_3_22_0_GA.xml new file mode 100644 index 0000000..ad65915 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_javassist_javassist_3_22_0_GA.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_jboss_jandex_2_0_3_Final.xml b/backend/.idea/libraries/Maven__org_jboss_jandex_2_0_3_Final.xml new file mode 100644 index 0000000..b841e21 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_jboss_jandex_2_0_3_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml b/backend/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml new file mode 100644 index 0000000..5f7dd01 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_mockito_mockito_core_2_15_0.xml b/backend/.idea/libraries/Maven__org_mockito_mockito_core_2_15_0.xml new file mode 100644 index 0000000..a742a6d --- /dev/null +++ b/backend/.idea/libraries/Maven__org_mockito_mockito_core_2_15_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml b/backend/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml new file mode 100644 index 0000000..af41e3b --- /dev/null +++ b/backend/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml b/backend/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml new file mode 100644 index 0000000..0bf8cf2 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml b/backend/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml new file mode 100644 index 0000000..c4c54d6 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml b/backend/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml new file mode 100644 index 0000000..6073e53 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml b/backend/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml new file mode 100644 index 0000000..20e8163 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_0_RELEASE.xml new file mode 100644 index 0000000..6f53ce1 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_0_RELEASE.xml new file mode 100644 index 0000000..bb1e179 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_devtools_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_devtools_2_0_0_RELEASE.xml new file mode 100644 index 0000000..11f80c1 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_devtools_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_0_RELEASE.xml new file mode 100644 index 0000000..da1a887 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_0_0_RELEASE.xml new file mode 100644 index 0000000..c479f04 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_0_0_RELEASE.xml new file mode 100644 index 0000000..ed5e1e3 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_0_RELEASE.xml new file mode 100644 index 0000000..250e96a --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_0_RELEASE.xml new file mode 100644 index 0000000..440dbd0 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_0_RELEASE.xml new file mode 100644 index 0000000..35e7c76 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_0_0_RELEASE.xml new file mode 100644 index 0000000..b292009 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_0_RELEASE.xml new file mode 100644 index 0000000..b3063f3 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_0_RELEASE.xml new file mode 100644 index 0000000..d1159de --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_0_0_RELEASE.xml new file mode 100644 index 0000000..d298a45 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_0_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_0_RELEASE.xml new file mode 100644 index 0000000..06ed00f --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_0_5_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_0_5_RELEASE.xml new file mode 100644 index 0000000..85aa25c --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_0_5_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_0_5_RELEASE.xml new file mode 100644 index 0000000..f48b9dc --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_aop_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_aop_5_0_4_RELEASE.xml new file mode 100644 index 0000000..42e3c72 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_aop_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_aspects_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_aspects_5_0_4_RELEASE.xml new file mode 100644 index 0000000..1f498dd --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_aspects_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_beans_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_beans_5_0_4_RELEASE.xml new file mode 100644 index 0000000..9d3252b --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_beans_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_context_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_context_5_0_4_RELEASE.xml new file mode 100644 index 0000000..24e83c9 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_context_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_core_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_core_5_0_4_RELEASE.xml new file mode 100644 index 0000000..2784300 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_core_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_expression_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_expression_5_0_4_RELEASE.xml new file mode 100644 index 0000000..8151535 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_expression_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_4_RELEASE.xml new file mode 100644 index 0000000..d0484b5 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_4_RELEASE.xml new file mode 100644 index 0000000..8b68fe1 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_orm_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_orm_5_0_4_RELEASE.xml new file mode 100644 index 0000000..6e8a76f --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_orm_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_test_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_test_5_0_4_RELEASE.xml new file mode 100644 index 0000000..e8317f4 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_test_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_tx_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_tx_5_0_4_RELEASE.xml new file mode 100644 index 0000000..e6f1139 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_tx_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_web_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_web_5_0_4_RELEASE.xml new file mode 100644 index 0000000..002d32d --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_web_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_4_RELEASE.xml b/backend/.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_4_RELEASE.xml new file mode 100644 index 0000000..0aed43d --- /dev/null +++ b/backend/.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_5_1.xml b/backend/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_5_1.xml new file mode 100644 index 0000000..474c910 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_5_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml b/backend/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml new file mode 100644 index 0000000..33ccf19 --- /dev/null +++ b/backend/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/.idea/vcs.xml b/backend/.idea/vcs.xml new file mode 100644 index 0000000..288b36b --- /dev/null +++ b/backend/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/backend/.idea/workspace.xml b/backend/.idea/workspace.xml new file mode 100644 index 0000000..d8da3c2 --- /dev/null +++ b/backend/.idea/workspace.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1538657724296 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..8e026f1 --- /dev/null +++ b/backend/README.md @@ -0,0 +1,3 @@ +# TAS_Projekt + +W katalogu src/main/database znajsuje się skrypt SQL, który należy wczytać i uruchomić w bazie MySQL przed uruchomieniem programu. diff --git a/backend/pom.xml b/backend/pom.xml new file mode 100644 index 0000000..c63793b --- /dev/null +++ b/backend/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + TCA + TCA_Project + 1.0-SNAPSHOT + jar + + TakeCareApp Application + Spring Boot Web Application + + + org.springframework.boot + spring-boot-starter-parent + 2.0.0.RELEASE + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + + + mysql + mysql-connector-java + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-tomcat + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + org.springframework.security + spring-security-web + 5.1.1.RELEASE + + + org.springframework.security + spring-security-config + 5.1.1.RELEASE + + + org.springframework.security + spring-security-core + 5.1.1.RELEASE + + + javax.xml.bind + jaxb-api + 2.3.0 + + + io.jsonwebtoken + jjwt + 0.9.1 + + + org.projectlombok + lombok + 1.18.16 + provided + + + org.postgresql + postgresql + 42.2.18 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + \ No newline at end of file diff --git a/backend/src/main/database/dump.sql b/backend/src/main/database/dump.sql new file mode 100644 index 0000000..c17e124 --- /dev/null +++ b/backend/src/main/database/dump.sql @@ -0,0 +1,181 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 10.15 +-- Dumped by pg_dump version 10.15 + +-- Started on 2020-12-19 22:52:46 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +-- +-- TOC entry 1 (class 3079 OID 12924) +-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: +-- + +CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; + + +-- +-- TOC entry 2815 (class 0 OID 0) +-- Dependencies: 1 +-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: +-- + +COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; + + +SET default_tablespace = ''; + +SET default_with_oids = false; + +-- +-- TOC entry 196 (class 1259 OID 24577) +-- Name: roles; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.roles ( + name character varying(255) NOT NULL +); + + +ALTER TABLE public.roles OWNER TO postgres; + +-- +-- TOC entry 198 (class 1259 OID 32808) +-- Name: users; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.users ( + id integer NOT NULL, + datebirth date NOT NULL, + email character varying(255) NOT NULL, + enabled boolean DEFAULT true, + gender character varying(255) NOT NULL, + login character varying(255) NOT NULL, + name character varying(255) NOT NULL, + password character varying(255) NOT NULL, + surname character varying(255) NOT NULL, + role character varying(255) NOT NULL +); + + +ALTER TABLE public.users OWNER TO postgres; + +-- +-- TOC entry 197 (class 1259 OID 32806) +-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.users_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.users_id_seq OWNER TO postgres; + +-- +-- TOC entry 2816 (class 0 OID 0) +-- Dependencies: 197 +-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; + + +-- +-- TOC entry 2675 (class 2604 OID 32811) +-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); + + +-- +-- TOC entry 2805 (class 0 OID 24577) +-- Dependencies: 196 +-- Data for Name: roles; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.roles (name) FROM stdin; +COMP +IND +\. + + +-- +-- TOC entry 2807 (class 0 OID 32808) +-- Dependencies: 198 +-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.users (id, datebirth, email, enabled, gender, login, name, password, surname, role) FROM stdin; +1 1970-01-01 koko@spoko.com f 0 przyklad Przykład $2a$10$Bgau.SVIBvX5IxOCY.JBBOgJXvXRIEdRIkEhYPPNe/VIGdv51U1W. Przykładowe IND +\. + + +-- +-- TOC entry 2817 (class 0 OID 0) +-- Dependencies: 197 +-- Name: users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.users_id_seq', 1, true); + + +-- +-- TOC entry 2678 (class 2606 OID 24581) +-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.roles + ADD CONSTRAINT roles_pkey PRIMARY KEY (name); + + +-- +-- TOC entry 2680 (class 2606 OID 32819) +-- Name: users uk_ow0gan20590jrb00upg3va2fn; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT uk_ow0gan20590jrb00upg3va2fn UNIQUE (login); + + +-- +-- TOC entry 2682 (class 2606 OID 32817) +-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); + + +-- +-- TOC entry 2683 (class 2606 OID 32820) +-- Name: users fk4c6vlshk8x83ifeoggi3exg3k; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT fk4c6vlshk8x83ifeoggi3exg3k FOREIGN KEY (role) REFERENCES public.roles(name); + + +-- Completed on 2020-12-19 22:52:46 + +-- +-- PostgreSQL database dump complete +-- + diff --git a/backend/src/main/java/project/DTO/RoleDTO.java b/backend/src/main/java/project/DTO/RoleDTO.java new file mode 100644 index 0000000..31f853a --- /dev/null +++ b/backend/src/main/java/project/DTO/RoleDTO.java @@ -0,0 +1,22 @@ +package project.DTO; + +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +public class RoleDTO implements Serializable { + + @Getter + @Setter + private String name; + + public RoleDTO(){ + + } + + public RoleDTO(String name){ + this.name=name; + + } +} diff --git a/backend/src/main/java/project/DTO/UserDTO.java b/backend/src/main/java/project/DTO/UserDTO.java new file mode 100644 index 0000000..fb40e5d --- /dev/null +++ b/backend/src/main/java/project/DTO/UserDTO.java @@ -0,0 +1,82 @@ +package project.DTO; + +import lombok.Getter; +import lombok.Setter; +import project.model.User; + +import java.io.Serializable; +import java.util.Date; + + +public class UserDTO implements Serializable { + + + @Getter + @Setter + private String name; + + @Getter + @Setter + private String surname; + + @Getter + @Setter + private String email; + + @Getter + @Setter + private String gender; + + @Getter + @Setter + private Date datebirth; + + @Getter + @Setter + private String login; + + @Getter + @Setter + private String password; + + @Getter + @Setter + private RoleDTO roleDTO; + + + + + public UserDTO(){ + + } + + public UserDTO(String login, String password) { + this.login = login; + this.password = password; + } + + public UserDTO(UserDTO userDTO) { + this.name = userDTO.getName(); + this.surname = userDTO.getSurname(); + this.email = userDTO.getEmail(); + this.gender = userDTO.getGender(); + this.datebirth = userDTO.getDatebirth(); + this.login = userDTO.getLogin(); + this.password = userDTO.getPassword(); + this.roleDTO= userDTO.getRoleDTO(); + } + + public UserDTO(User user) { + this.name = user.getName(); + this.surname = user.getSurname(); + this.email = user.getEmail(); + this.gender = user.getGender(); + this.datebirth = user.getDatebirth(); + this.login = user.getLogin(); + + } + + + + +} diff --git a/backend/src/main/java/project/TakeCareApp.java b/backend/src/main/java/project/TakeCareApp.java new file mode 100644 index 0000000..62e5b23 --- /dev/null +++ b/backend/src/main/java/project/TakeCareApp.java @@ -0,0 +1,25 @@ +package project; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; + +@SpringBootApplication +@EnableJpaRepositories("project.repositories") + +public class TakeCareApp { + public static void main(String[] args){ + SpringApplication.run(TakeCareApp.class,args); + + + } + + + +} diff --git a/backend/src/main/java/project/config/JwtAuthenticationEntryPoint.java b/backend/src/main/java/project/config/JwtAuthenticationEntryPoint.java new file mode 100644 index 0000000..492a49a --- /dev/null +++ b/backend/src/main/java/project/config/JwtAuthenticationEntryPoint.java @@ -0,0 +1,22 @@ +package project.config; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.stereotype.Component; + + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { + + + @Override + public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException{ + httpServletResponse.setContentType("application/json"); + new DefaultRedirectStrategy().sendRedirect(httpServletRequest,httpServletResponse,"/api/login"); + } +} diff --git a/backend/src/main/java/project/config/JwtAuthenticationFilter.java b/backend/src/main/java/project/config/JwtAuthenticationFilter.java new file mode 100644 index 0000000..c6faf6b --- /dev/null +++ b/backend/src/main/java/project/config/JwtAuthenticationFilter.java @@ -0,0 +1,79 @@ +package project.config; + +import io.jsonwebtoken.ExpiredJwtException; +import io.jsonwebtoken.SignatureException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; +import project.services.UserServiceImpl; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + + +import static project.config.SecurityConfiguration.TOKEN_HEADER; +import static project.config.SecurityConfiguration.TOKEN_SCHEME; + +@Component +public class JwtAuthenticationFilter extends OncePerRequestFilter { + + @Autowired + private UserServiceImpl userDetailsService; + + @Autowired + private TokenHelper tokenHelper; + + @Override + protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws IOException, ServletException { + + HttpServletRequest request = httpServletRequest; + HttpServletResponse response = httpServletResponse; + + String header = httpServletRequest.getHeader(TOKEN_HEADER); + String name = null; + String tokenAuth = null; + + if(header!=null && header.startsWith(TOKEN_SCHEME)){ + tokenAuth = header.replace(TOKEN_SCHEME,""); + try{ + name = tokenHelper.getUsernameFromToken(tokenAuth); + } catch (IllegalArgumentException e) { + request.setAttribute("token","token is invalid"); + logger.error("an error occured during getting username from token", e); + } catch (ExpiredJwtException e) { + request.setAttribute("token","token is expired"); + logger.warn("the token is expired and not valid anymore", e); + } catch(SignatureException e){ + request.setAttribute("token","token is invalid"); + logger.error("Authentication Failed. Username or Password not valid."); + } + + }else{ + logger.warn("Couldn't find Bearer String"); + } + if(name != null && SecurityContextHolder.getContext().getAuthentication()==null){ + + UserDetails userDetails = userDetailsService.loadUserByUsername(name); + + if(this.tokenHelper.validateToken(tokenAuth,userDetails)){ + UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(userDetails,SecurityContextHolder.getContext().getAuthentication(),userDetails.getAuthorities()); + String token = this.tokenHelper.refreshToken(tokenAuth); + + request.setAttribute("token",token); + + SecurityContextHolder.getContext().setAuthentication(auth); + logger.info("Authenticated user "+name); + + } + } + + + filterChain.doFilter(request,response); + + } +} diff --git a/backend/src/main/java/project/config/SecurityConfiguration.java b/backend/src/main/java/project/config/SecurityConfiguration.java new file mode 100644 index 0000000..53f792b --- /dev/null +++ b/backend/src/main/java/project/config/SecurityConfiguration.java @@ -0,0 +1,111 @@ +package project.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.CorsConfigurationSource; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import project.services.UserServiceImpl; + +import java.util.Arrays; + +@EnableGlobalMethodSecurity(prePostEnabled = true) +@EnableWebSecurity +@Configuration +public class SecurityConfiguration extends WebSecurityConfigurerAdapter { + + @Autowired + private UserServiceImpl userDetailsService; + + @Bean + public BCryptPasswordEncoder passwordEncoder() { + BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); + return bCryptPasswordEncoder; + } + + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + @Override + public void configure(AuthenticationManagerBuilder authManBuild) throws Exception{ + authManBuild + .userDetailsService(userDetailsService) + .passwordEncoder(passwordEncoder()); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + + + http.cors().and().csrf().disable() + .authorizeRequests() + .antMatchers("/profile**").hasAnyAuthority("COMP","IND") + .antMatchers("/login").anonymous() + .antMatchers("/register").anonymous() + .and() + .formLogin() + .loginPage("/login") + .and() + .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); + http.addFilterBefore(jwtAuthenticationFilter(),UsernamePasswordAuthenticationFilter.class); + + } + + + public static final String TOKEN_HEADER = "Authorization"; + public static final String TOKEN_SCHEME = "Bearer "; + public static final String TOKEN_KEY = "TakeCareApp"; + public static final long TOKEN_VALIDITY = 5*60; + + + + + @Autowired + private JwtAuthenticationEntryPoint unauthHandler; + + @Bean + public JwtAuthenticationFilter jwtAuthenticationFilter(){ + + return new JwtAuthenticationFilter(); + } + + @Bean + public CorsConfigurationSource corsConfigurationSource() { + CorsConfiguration configuration = new CorsConfiguration(); + configuration.setAllowedOrigins(Arrays.asList("*")); + configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")); + configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token")); + configuration.setExposedHeaders(Arrays.asList("x-auth-token")); + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/api/**", configuration); + return source; + } + + + @Autowired + private AuthenticationManager authenticationManager; + + + + + + + + + + +} diff --git a/backend/src/main/java/project/config/TokenHelper.java b/backend/src/main/java/project/config/TokenHelper.java new file mode 100644 index 0000000..48526c3 --- /dev/null +++ b/backend/src/main/java/project/config/TokenHelper.java @@ -0,0 +1,106 @@ +package project.config; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Component; + +import project.model.User; + +import java.io.Serializable; +import java.util.*; + +import static project.config.SecurityConfiguration.TOKEN_KEY; +import static project.config.SecurityConfiguration.TOKEN_VALIDITY; + +@Component +public class TokenHelper implements Serializable { + + + //Generate Token with userID,role,name + + public String generateToken(User user) { + Claims claims = Jwts.claims().setSubject(user.getName()); + claims.put("userId",user.getId()); + claims.put("role",user.getRole().getName()); + + return Jwts.builder() + .setClaims(claims) + .setIssuer("http://localhost:8080") + .setIssuedAt(new Date(System.currentTimeMillis())) + .setExpiration(new Date(System.currentTimeMillis()+TOKEN_VALIDITY*1000)) + .signWith(SignatureAlgorithm.HS256,TOKEN_KEY) + .compact(); + } + + public String refreshToken(String token){ + Claims claims = getAllClaimsFromToken(token); + return Jwts.builder() + .setClaims(claims) + .setIssuer("http://localhost:8080") + .setIssuedAt(new Date(System.currentTimeMillis())) + .setExpiration(new Date(System.currentTimeMillis()+TOKEN_VALIDITY*1000)) + .signWith(SignatureAlgorithm.HS256,TOKEN_KEY) + .compact(); + + } + + public Claims getAllClaimsFromToken(String token){ + + return Jwts.parser() + .setSigningKey(TOKEN_KEY) + .parseClaimsJws(token) + .getBody(); + } + + + + public String getUsernameFromToken(String token){ + + Claims claims = getAllClaimsFromToken(token); + return claims.getSubject(); + } + + public String getAuthoritiesFromToken(String token){ + Claims claims = getAllClaimsFromToken(token); + String auth = (String)claims.get("role"); + return auth; + } + + public boolean validateToken(String token,UserDetails userDetails){ + String userName = getUsernameFromToken(token); + String tokenAuth = getAuthoritiesFromToken(token); + String userDetailsAuth = userDetails.getAuthorities() + .stream() + .findFirst() + .get() + .getAuthority(); + + if(userName.contentEquals(userDetails.getUsername()) + && !isTokenExpired(token) + && tokenAuth.contentEquals(userDetailsAuth)){ + return true; + } + else{ + return false; + } + } + + private Date getExpirationDate(String token) { + + Claims claims = getAllClaimsFromToken(token); + return claims.getExpiration(); + } + + public boolean isTokenExpired(String token){ + Date currentTime = new Date(System.currentTimeMillis()); + Date tokenTime = getExpirationDate(token); + if(currentTime.after(tokenTime)){ + return true; + } + else return false; + } + + +} diff --git a/backend/src/main/java/project/controllers/AuthenticationController.java b/backend/src/main/java/project/controllers/AuthenticationController.java new file mode 100644 index 0000000..49f55f9 --- /dev/null +++ b/backend/src/main/java/project/controllers/AuthenticationController.java @@ -0,0 +1,87 @@ +package project.controllers; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.web.bind.annotation.*; +import project.DTO.UserDTO; +import project.config.TokenHelper; + +import project.model.User; +import project.services.UserService; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +@CrossOrigin(origins = "http://localhost:4200") +@RestController +@RequestMapping("/api") +public class AuthenticationController { + + @Autowired + private AuthenticationManager authenticationManager; + + @Autowired + TokenHelper tokenHelper; + + @Autowired + UserService userService; + + @Autowired + private BCryptPasswordEncoder bCryptPasswordEncoder; + + @PreAuthorize("isAnonymous()") + @RequestMapping(value = "/login",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public Map generateToken(@RequestBody UserDTO loginForm, + HttpServletRequest request, + HttpServletResponse httpServletResponse){ + + + String token=null; + Map map = new HashMap<>(); + + System.out.println(loginForm.getLogin()); + System.out.println(loginForm.getPassword()); + + + + Optional userFromDatabase = this.userService.getUsersByLogin(loginForm.getLogin()); + + Authentication authentication =null; + + + if(userFromDatabase.isPresent()){ + + authentication = this.authenticationManager + .authenticate(new UsernamePasswordAuthenticationToken(loginForm.getLogin(),loginForm.getPassword())); + + SecurityContextHolder.getContext().setAuthentication(authentication); + + User authUser = userFromDatabase.get(); + token = this.tokenHelper.generateToken(authUser); + map.put("token",token); + map.put("message","Jesteś zalogowany jako "+authUser.getName()+" "+authUser.getSurname()); + httpServletResponse.setStatus(200); + return map; + } + else{ + map.put("message","Niepoprawne login lub hasło"); + map.put("token",token); + httpServletResponse.setStatus(460); + return map; + } + + + + } + +} diff --git a/backend/src/main/java/project/controllers/ControllersExceptionHandler.java b/backend/src/main/java/project/controllers/ControllersExceptionHandler.java new file mode 100644 index 0000000..017c9ec --- /dev/null +++ b/backend/src/main/java/project/controllers/ControllersExceptionHandler.java @@ -0,0 +1,22 @@ +package project.controllers; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +import java.util.HashMap; +import java.util.Map; + +@ControllerAdvice +public class ControllersExceptionHandler { + + @ExceptionHandler(HttpMessageNotReadableException.class) + public ResponseEntity> handle(){ + Map map = new HashMap<>(); + map.put("message","Wprowadzono niepoprawny typ danych"); + + return new ResponseEntity>(map,HttpStatus.BAD_REQUEST); + } +} diff --git a/backend/src/main/java/project/controllers/UserController.java b/backend/src/main/java/project/controllers/UserController.java new file mode 100644 index 0000000..55e7dcc --- /dev/null +++ b/backend/src/main/java/project/controllers/UserController.java @@ -0,0 +1,174 @@ +package project.controllers; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.type.filter.RegexPatternTypeFilter; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.web.bind.annotation.*; +import project.DTO.UserDTO; +import project.model.*; +import project.services.GeneratorDTO; +import project.services.RoleService; +import project.services.UserService; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.*; +import java.util.regex.Pattern; + + +@CrossOrigin(origins = "http://localhost:4200") + +@RestController +@RequestMapping("/api") +public class UserController { + + @Autowired + private UserService userService; + @Autowired + private RoleService roleService; + @Autowired + private GeneratorDTO generatorDTO; + + + + + @Autowired + private BCryptPasswordEncoder bCryptPasswordEncoder; + + @PreAuthorize("isAnonymous()") + @RequestMapping(value = "/register",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public Map addUser(@RequestBody @Valid @NotNull UserDTO userDTO, + HttpServletRequest request, + HttpServletResponse httpServletResponse){ + + + Map map = new HashMap<>(); + + Object token = request.getAttribute("token"); + map.put("token",token); + + System.out.println("REGISTER IN"); + System.out.println(userDTO.getLogin()); + System.out.println(userDTO.getPassword()); + + Optional users = this.userService.getUsersByLogin(userDTO.getLogin()); + + + Pattern pName =Pattern.compile("^[A-Z][a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż]{2,15}$"); + Pattern pSurname =Pattern.compile("^[A-Z][a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż]{2,20}$"); + Pattern pEmail =Pattern.compile("^[a-z]+[0-9]*@([a-z]{2,10}\\.)+[a-z]{2,5}$"); + Pattern pLogin =Pattern.compile("^([a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż]+[0-9\\-\\_]*){5,20}$"); + Pattern pPassword =Pattern.compile("^([a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż]{5,}[0-9]{5,}[a-zA-ZĄąĆćĘꣳŃńÓ󌜏źŻż0-9]*)+$"); + + + if(users.isPresent()){ + + map.put("message","Wprowadzony użytkownik już istnieje"); + httpServletResponse.setStatus(462); + return map; + + } + + else if(!pName.matcher(userDTO.getName()).matches() | !pSurname.matcher(userDTO.getSurname()).matches() | + !pEmail.matcher(userDTO.getEmail()).matches() | !pLogin.matcher(userDTO.getLogin()).matches() | + !pPassword.matcher(userDTO.getPassword()).matches()){ + + System.out.println(userDTO.getName() + " " + pName.matcher(userDTO.getName()).matches()); + System.out.println(userDTO.getSurname() + " " + pSurname.matcher(userDTO.getSurname()).matches()); + System.out.println(userDTO.getEmail() + " " + pEmail.matcher(userDTO.getEmail()).matches()); + System.out.println(userDTO.getLogin() + " " + pLogin.matcher(userDTO.getLogin()).matches()); + System.out.println(userDTO.getPassword() + " " + pPassword.matcher(userDTO.getPassword()).matches()); + + map.put("message","Niepoprawny login lub hasło"); + + httpServletResponse.setStatus(461); + return map;} + + + else{ + + + User registerUser = new User(); + + + + registerUser.setName(userDTO.getName()); + registerUser.setSurname(userDTO.getSurname()); + registerUser.setEmail(userDTO.getEmail()); + registerUser.setGender(userDTO.getGender()); + registerUser.setDatebirth(userDTO.getDatebirth()); + registerUser.setLogin(userDTO.getLogin()); + + String pass = this.bCryptPasswordEncoder.encode(userDTO.getPassword()); + + System.out.println(pass); + registerUser.setPassword(pass); + + + + Role role = this.roleService.getRoleByName(userDTO.getRoleDTO().getName()); + registerUser.setRole(role); + + + this.userService.addUser(registerUser); + map.put("message", "Zostałeś pomyślnie zarejestrowany"); + httpServletResponse.setStatus(201); + return map; + } + + + } + + + @PreAuthorize("hasAnyAuthority('COMP','IND')") + @RequestMapping(value="/profile/{id}",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> getProfileInfo(HttpServletRequest request, + @PathVariable int id){ + Map map = new HashMap<>(); + UserDetails userDetails = (UserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal(); + Optional user = userService.getUsersByLogin(userDetails.getUsername()); + int userId = user.get().getId(); + + String userRole = user.get().getRole().getName(); + + + Object token = request.getAttribute("token"); + map.put("token",token); + + + User userProfile = this.userService.getUserById(id); + if(userProfile!=null) { + + String userProfileRole = userProfile.getRole().getName(); + + if (userId == id) { + map.put("profil", this.generatorDTO.generateUserDTO(userProfile)); + return new ResponseEntity>(map, HttpStatus.OK); + }else { + map.put("message", "Nie masz dostępu do tej strony"); + return new ResponseEntity>(map, HttpStatus.BAD_REQUEST); + } + + + }else{ + map.put("message", "Profil nie istnieje"); + return new ResponseEntity>(map, HttpStatus.BAD_REQUEST); + + } + + + + } + + +} diff --git a/backend/src/main/java/project/model/CustomUserDetails.java b/backend/src/main/java/project/model/CustomUserDetails.java new file mode 100644 index 0000000..e7b7bf0 --- /dev/null +++ b/backend/src/main/java/project/model/CustomUserDetails.java @@ -0,0 +1,53 @@ +package project.model; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class CustomUserDetails extends User implements UserDetails { + + public CustomUserDetails(User user){ + super(user); + } + + @Override + public Collection getAuthorities() { + List authorityList = new ArrayList(); + authorityList.add(new SimpleGrantedAuthority(getRole().getName())); + return null; + } + + @Override + public String getUsername() { + return super.getLogin(); + } + + @Override + public String getPassword() { + return super.getPassword(); + } + + @Override + public boolean isAccountNonExpired() { + return false; + } + + @Override + public boolean isEnabled() { + return super.isEnabled(); + } + + @Override + public boolean isAccountNonLocked() { + return false; + } + + @Override + public boolean isCredentialsNonExpired() { + return false; + } +} diff --git a/backend/src/main/java/project/model/Role.java b/backend/src/main/java/project/model/Role.java new file mode 100644 index 0000000..e48868c --- /dev/null +++ b/backend/src/main/java/project/model/Role.java @@ -0,0 +1,45 @@ +package project.model; + + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; +import java.util.Set; + +@Entity +@Table(name="Roles") +public class Role implements Serializable { + + + @Id + @Column(name="name",nullable = false) + private String name; + + @OneToMany(mappedBy = "role",orphanRemoval = true, cascade = CascadeType.PERSIST) + @JsonIgnore + private List user; + + + + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getUser() { + return user; + } + + public void setUser(List user) { + this.user = user; + } + + +} diff --git a/backend/src/main/java/project/model/User.java b/backend/src/main/java/project/model/User.java new file mode 100644 index 0000000..7e47c56 --- /dev/null +++ b/backend/src/main/java/project/model/User.java @@ -0,0 +1,108 @@ +package project.model; + + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; +import lombok.Getter; +import lombok.Setter; +import org.springframework.security.core.userdetails.UserDetails; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.Set; + +@Entity +@Table(name="Users") +public class User implements Serializable { + + @Getter + @Setter + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name="id",nullable = false) + private int id; + + @Getter + @Setter + @Column(name="name",nullable = false) + private String name; + + @Getter + @Setter + @Column(name="surname",nullable = false) + private String surname; + + @Getter + @Setter + @Column(name="email",nullable = false) + private String email; + + @Getter + @Setter + @Column(name="gender",nullable = false) + private String gender; + + @Getter + @Setter + @Column(name="datebirth",nullable = false) + @Basic + @Temporal(TemporalType.DATE) + private Date datebirth; + + @Getter + @Setter + @Column(name="login",nullable = false,unique = true) + private String login; + + @Getter + @Setter + @Column(name="password",nullable = false) + private String password; + + @Getter + @Setter + @Column(name="enabled",columnDefinition = "boolean default true") + private boolean enabled; + + @Getter + @Setter + @ManyToOne + @JoinColumn(name = "role",nullable=false) + private Role role; + + public User(){ + + } + + public User(String name, String surname, String email, String gender, Date datebirth, String login, String password, Role role) { + this.name = name; + this.surname = surname; + this.email = email; + this.gender = gender; + this.datebirth = datebirth; + this.login = login; + this.password = password; + this.role = role; + } + + public User(User user) { + this.name = user.getName(); + this.surname = user.getSurname(); + this.email = user.getEmail(); + this.gender = user.getGender(); + this.datebirth = user.getDatebirth(); + this.login = user.getLogin(); + this.password = user.getPassword(); + this.role = user.getRole(); + } + + + + + + + +} diff --git a/backend/src/main/java/project/repositories/RoleRepository.java b/backend/src/main/java/project/repositories/RoleRepository.java new file mode 100644 index 0000000..26f5fee --- /dev/null +++ b/backend/src/main/java/project/repositories/RoleRepository.java @@ -0,0 +1,16 @@ +package project.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import project.model.Role; + +@Repository +public interface RoleRepository extends JpaRepository { + + public Role findById(int id); + + @Query(value="SELECT * FROM roles r WHERE r.name LIKE %:name%", nativeQuery = true) + public Role findByName(@Param("name") String name); +} diff --git a/backend/src/main/java/project/repositories/UserRepository.java b/backend/src/main/java/project/repositories/UserRepository.java new file mode 100644 index 0000000..a5847a0 --- /dev/null +++ b/backend/src/main/java/project/repositories/UserRepository.java @@ -0,0 +1,19 @@ +package project.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import project.model.User; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface UserRepository extends JpaRepository { + + public User findById(int id); + public Optional findByLogin(String login); + public Optional findByLoginAndPassword(String login,String password); + + public User findOneByName(String username); +} diff --git a/backend/src/main/java/project/services/GeneratorDTO.java b/backend/src/main/java/project/services/GeneratorDTO.java new file mode 100644 index 0000000..d69263f --- /dev/null +++ b/backend/src/main/java/project/services/GeneratorDTO.java @@ -0,0 +1,22 @@ +package project.services; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import project.DTO.RoleDTO; +import project.DTO.UserDTO; +import project.model.User; + +import java.io.Serializable; + +@Service +public class GeneratorDTO implements Serializable { + + public UserDTO generateUserDTO(User user){ + UserDTO userDTO = new UserDTO(user); + RoleDTO roleDTO = new RoleDTO(user.getRole().getName()); + userDTO.setRoleDTO(roleDTO); + + return userDTO; + + } +} diff --git a/backend/src/main/java/project/services/RoleService.java b/backend/src/main/java/project/services/RoleService.java new file mode 100644 index 0000000..f1db2ef --- /dev/null +++ b/backend/src/main/java/project/services/RoleService.java @@ -0,0 +1,9 @@ +package project.services; + +import project.model.Role; + +public interface RoleService { + + public Role getRoleById(int id); + public Role getRoleByName(String name); +} diff --git a/backend/src/main/java/project/services/RoleServiceImpl.java b/backend/src/main/java/project/services/RoleServiceImpl.java new file mode 100644 index 0000000..1ba7a5f --- /dev/null +++ b/backend/src/main/java/project/services/RoleServiceImpl.java @@ -0,0 +1,24 @@ +package project.services; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import project.model.Role; +import project.repositories.RoleRepository; + +@Service +public class RoleServiceImpl implements RoleService{ + + @Autowired + RoleRepository roleRepository; + + @Override + public Role getRoleById(int id) { + return this.roleRepository.findById(id); + } + + @Override + public Role getRoleByName(String name) { + return this.roleRepository.findByName(name); + } +} diff --git a/backend/src/main/java/project/services/UserService.java b/backend/src/main/java/project/services/UserService.java new file mode 100644 index 0000000..57ed7bd --- /dev/null +++ b/backend/src/main/java/project/services/UserService.java @@ -0,0 +1,20 @@ +package project.services; + +import project.model.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Optional; + +public interface UserService { + + public User addUser(User user); + + public Optional getUsersByLogin(String login); + public Optional getUsersByLoginAndPassword(String login,String password); + public void deleteUser(int id); + public User getUserById(int id); + public List getAllUsers(); + + +} diff --git a/backend/src/main/java/project/services/UserServiceImpl.java b/backend/src/main/java/project/services/UserServiceImpl.java new file mode 100644 index 0000000..65e969d --- /dev/null +++ b/backend/src/main/java/project/services/UserServiceImpl.java @@ -0,0 +1,81 @@ +package project.services; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; +import project.model.CustomUserDetails; +import project.model.User; +import project.repositories.UserRepository; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.springframework.security.web.context.HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY; + +@Service +public class UserServiceImpl implements UserService,UserDetailsService { + + @Autowired + private UserRepository userRepository; + + @Autowired + private AuthenticationManager authManager; + + public User addUser(User user){ + + return this.userRepository.save(user); + } + + public void deleteUser(int id){ + this.userRepository.deleteById(id); + } + + public User getUserById(int id){ + return this.userRepository.findById(id); + } + + public Optional getUsersByLogin(String login){ + return this.userRepository.findByLogin(login); + } + + public Optional getUsersByLoginAndPassword(String login,String password){ + return this.userRepository.findByLoginAndPassword(login,password); + } + + public List getAllUsers(){ + return this.userRepository.findAll(); + } + + public List getAuthorities(User user){ + List authorityList = new ArrayList(); + authorityList.add(new SimpleGrantedAuthority(user.getRole().getName())); + return authorityList; + } + + @Override + public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException { + Optional optionalUser = this.userRepository.findByLogin(s); + if(optionalUser.isPresent()){ + return new org.springframework.security.core.userdetails. + User(optionalUser.get().getLogin(), + optionalUser.get().getPassword(), + getAuthorities(optionalUser.get())); + + }else{ + throw new UsernameNotFoundException("username not found"); + } + + } + +} diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties new file mode 100644 index 0000000..650d2e2 --- /dev/null +++ b/backend/src/main/resources/application.properties @@ -0,0 +1,26 @@ +## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) +spring.datasource.url = jdbc:postgresql://localhost:5432/takecareapp?hibernate?useUnicode=yes&characterEncoding=UTF-8 + +#spring.jpa.generate-ddl=true + +#hibernate?useUnicode=yes&characterEncoding=UTF-8 +spring.datasource.username = postgres +spring.datasource.password = postgres + +#useSSL=false + +## Hibernate Properties +# The SQL dialect makes Hibernate generate better SQL for the chosen database +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect +spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false +# Hibernate ddl auto (create, create-drop, validate, update) +spring.jpa.hibernate.ddl-auto = update + + + +#Tomcat session timeout nir moze byc mniejszy niz 1 minuta +#server.servlet.session.timeout=60s + +#spring.session.store-type=jdbc +#spring.session.jdbc.initialize-schema=always +#spring.session.timeout.seconds=10