From 8db237cddd98ead0dec85adfd2fed4316ee7900e Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Wed, 22 Feb 2017 20:40:09 -0500 Subject: [PATCH] Have users have upload permissions. Make sure upload tab only shows up then. --- src/WebInterface.cpp | 3 ++- src/db/User.h | 2 ++ src/ui/LoginInterface.cpp | 1 + src/ui/PlayerInterface.cpp | 1 - 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/WebInterface.cpp b/src/WebInterface.cpp index 86a5950..447eb45 100644 --- a/src/WebInterface.cpp +++ b/src/WebInterface.cpp @@ -46,7 +46,6 @@ WebInterface::WebInterface(const Wt::WEnvironment& env) : Wt::WApplication(env) root()->addWidget(priv_int->loginUI); priv_int->loginUI->animateShow(Wt::WAnimation(Wt::WAnimation::AnimationEffect::SlideInFromTop)); priv_int->loginUI->checkSessionValidity(); - if(currentUser.isAdmin) priv_int->playerUI->mainDisplay->addTab(priv_int->playerUI->adminPane, "Admin", Wt::WTabWidget::LazyLoading); notificationSlot.setJavaScript(getNotificationJs("")); } @@ -70,6 +69,8 @@ void WebInterface::loginCompleted() priv_int->playerUI->updateDetailsFromServer(GroovePlayerMgr::getInstance()->currentTrack); priv_int->playerUI->updateVoteableTracksFromServer(GroovePlayerMgr::getInstance()->currentVoteBatch); priv_int->playerUI->updateVoteTrackState(); + if(currentUser.canUpload) priv_int->playerUI->mainDisplay->addTab(priv_int->playerUI->uploadPane, "Upload Track", Wt::WTabWidget::LazyLoading); + if(currentUser.isAdmin) priv_int->playerUI->mainDisplay->addTab(priv_int->playerUI->adminPane, "Admin", Wt::WTabWidget::LazyLoading); } void WebInterface::playPauseActionFromServer(User userPausing, bool pause) diff --git a/src/db/User.h b/src/db/User.h index d031baa..08f0767 100644 --- a/src/db/User.h +++ b/src/db/User.h @@ -31,6 +31,7 @@ public: std::string passwordSalt; bool isDisabled; bool isAdmin; + bool canUpload; std::string loginCookieToken; template @@ -41,6 +42,7 @@ public: Wt::Dbo::field(a, passwordSalt, "salt"); Wt::Dbo::field(a, isDisabled, "disabled"); Wt::Dbo::field(a, isAdmin, "admin"); + Wt::Dbo::field(a, canUpload, "canupload"); Wt::Dbo::field(a, loginCookieToken, "cookie"); } }; diff --git a/src/ui/LoginInterface.cpp b/src/ui/LoginInterface.cpp index 8fa7126..32f5ed8 100644 --- a/src/ui/LoginInterface.cpp +++ b/src/ui/LoginInterface.cpp @@ -131,6 +131,7 @@ void LoginInterface::createUser(Wt::Dbo::Session* session, std::string username, user->isAdmin = isAdmin; user->username = username; user->isDisabled = false; + user->canUpload = true; user->passwordSalt = Wt::WRandom::generateId(); user->passwordHash = hasher.compute(rawPassword, user->passwordSalt); user->loginCookieToken = Wt::WRandom::generateId(); diff --git a/src/ui/PlayerInterface.cpp b/src/ui/PlayerInterface.cpp index a5a1268..d5b9aad 100644 --- a/src/ui/PlayerInterface.cpp +++ b/src/ui/PlayerInterface.cpp @@ -125,7 +125,6 @@ PlayerInterface::PlayerInterface(WebInterface* app) interfaceLayout->addWidget(mainDisplay); mainDisplay->addTab(voteMetaContainer,"Up Next",Wt::WTabWidget::PreLoading); mainDisplay->addTab(requestPane, "Make Request", Wt::WTabWidget::LazyLoading); - mainDisplay->addTab(uploadPane, "Upload Track", Wt::WTabWidget::LazyLoading); playControlWidget->addStyleClass("panel"); playControlWidget->addStyleClass("panel-default"); playControlWidget->decorationStyle().setBackgroundColor(Wt::WColor("gainsboro")); -- GitLab