Skip to content

Commit

Permalink
Check authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
ciukstar committed Nov 18, 2023
1 parent 6440e85 commit e60be58
Show file tree
Hide file tree
Showing 65 changed files with 1,571 additions and 1,094 deletions.
1 change: 1 addition & 0 deletions config/models.persistentmodels
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ User
name Text
password Text
admin Bool
analyst Bool
fullName Text Maybe
email Text Maybe
UniqueUser name
Expand Down
3 changes: 0 additions & 3 deletions config/robots.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
User-agent: *
Disallow: /bookings/calendar/
Disallow: /admin/
Disallow: /stats/
21 changes: 20 additions & 1 deletion messages/en.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
OnlyAdminisHaveAccess: Only administrators can manage this data
AuthorizationRequired: Authorization required
OnlyAnalystsHaveAccess: Only analysts have access to analytical reports
LoginAsAdminToContinue: Please login as administrator to continue
LoginAsAnalystToContinue: Please log in as an analyst to continue
Analyst: Analyst
NoRequestsFoundForThisDay: No requests found for this day
LoginAsEmployeeToContinue: Please login as employee to continue
LoginToContinue: Please login to continue
Expand Down Expand Up @@ -330,6 +336,9 @@ AppName: Salon
MetaKeywords: beauty, salon, application
MetaDescription: Beauty Salon Application

DemoSampleOne: Click on the
DemoSampleTwo: icon to get a list of demo accounts

Documentation: Docs
Doc001 hrefHome@Text: The <a href=#{hrefHome}>"Salon"</a> application provides the opportunity to publish and advertise the services of beauty salon owners on the web.

Expand Down Expand Up @@ -361,4 +370,14 @@ Doc007: Currently, the app only supports one business. Multi-business support is

Doc008 href@Text: Application users, including clients, employees and administrators, can be registered through the <a href=#{href}>"Registration"</a> form.

Doc009 href@Text: Users can also be managed by administrators in the section <a href=#{href}>“Users”</a> of the group “Data”.
Doc009 href@Text: Users can also be managed by administrators in the section <a href=#{href}>“Users”</a> of the group “Data”.

Doc010: A registered user can have several roles at the same time.

Doc011: An administrator can assign the role "Administrator" to any other registered user. The role “Administrator” is required in order to have access to any section of the group “Data”. That is, manage any application data.

Doc012: An administrator can assign the role "Analyst" to any other registered user. The role “Analyst” is required in order to have access to any section of the group “Analytics”.

Doc013: Any user who is also registered as a staff member has the role "Employee". A user with the role "Employee" has access to the service request queue.

Doc014: All users can become customers by simply registering and using the services offered.
23 changes: 22 additions & 1 deletion messages/fr.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
OnlyAdminisHaveAccess: Seuls les administrateurs peuvent gérer ces données
AuthorizationRequired: Autorisation requise
OnlyAnalystsHaveAccess: Seuls les analystes ont accès aux rapports analytiques
LoginAsAdminToContinue: Veuillez vous connecter en tant qu'administrateur pour continuer
LoginAsAnalystToContinue: Veuillez vous connecter en tant qu'analyste pour continuer
Analyst: Analyste
NoRequestsFoundForThisDay: Aucune demande trouvée pour ce jour
LoginAsEmployeeToContinue: Veuillez vous connecter en tant qu'employé pour continuer
LoginToContinue: Veuillez vous connecter pour continuer
Expand Down Expand Up @@ -330,6 +336,11 @@ AppName: Salon
MetaKeywords: beauté, salon, application
MetaDescription: Application de salon de beauté


DemoSampleOne: Cliquez sur l'icône
DemoSampleTwo: pour obtenir une liste des comptes d'utilisateurs de démonstration


Documentation: Documentation
Doc001 hrefHome: L'application <a href=#{hrefHome}>« Salon »</a> offre la possibilité de publier et d'annoncer les services des propriétaires de salons de beauté sur le Web.

Expand Down Expand Up @@ -361,4 +372,14 @@ Doc007: Actuellement, l'application ne prend en charge qu'une seule entreprise.

Doc008 href: Les utilisateurs de l'application, y compris les clients, les employés et les administrateurs, peuvent être enregistrés via le formulaire <a href=#{href}>« Inscription »</a>.

Doc009 href: De plus, les utilisateurs peuvent être gérés par les administrateurs dans la section <a href=#{href}>« Utilisateurs »</a> du groupe « Données ».
Doc009 href: De plus, les utilisateurs peuvent être gérés par les administrateurs dans la section <a href=#{href}>« Utilisateurs »</a> du groupe « Données ».

Doc010: Un utilisateur enregistré peut avoir plusieurs rôles en même temps.

Doc011: Un administrateur peut attribuer le rôle « Administrateur » à tout autre utilisateur enregistré. Le rôle « Administrateur » est requis pour avoir accès à n'importe quelle section du groupe « Données ». Autrement dit, gérez toutes les données d’application.

Doc012: Un administrateur peut attribuer le rôle « Analyste » à tout autre utilisateur enregistré. Le rôle « Analyste » est requis pour avoir accès à n'importe quelle section du groupe « Analyse ». Autrement dit, pour générer des rapports analytiques.

Doc013: Tout utilisateur également enregistré en tant que membre du personnel a le rôle "Employé". Un utilisateur avec le rôle « Employé » a accès à la file d'attente des demandes de service.

Doc014: Tous les utilisateurs peuvent devenir clients par simple inscription et utilisation des services proposés.
23 changes: 22 additions & 1 deletion messages/ro.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
OnlyAdminisHaveAccess: Numai administratorii pot gestiona aceste date
AuthorizationRequired: Este necesară autorizarea
OnlyAnalystsHaveAccess: Doar analiștii au acces la rapoartele analitice
LoginAsAdminToContinue: Vă rugăm să vă conectați ca administrator pentru a continua
LoginAsAnalystToContinue: Vă rugăm să vă conectați ca analist pentru a continua
Analyst: Analist
NoRequestsFoundForThisDay: Nu au fost găsite solicitări pentru această zi
LoginAsEmployeeToContinue: Vă rugăm să vă autentificați ca angajat pentru a continua
LoginToContinue: Vă rugăm să vă conectați pentru a continua
Expand Down Expand Up @@ -330,6 +336,11 @@ AppName: Salon
MetaKeywords: frumusețe, salon, aplicație
MetaDescription: Aplicația salon de frumusețe


DemoSampleOne: Faceți clic pe pictograma
DemoSampleTwo: pentru a obține o listă de conturi de utilizator demonstrative


Documentation: Documentație
Doc001 hrefHome: Aplicația <a href=#{hrefHome}>„Salon”</a> oferă posibilitatea de a publica și de a face publicitate serviciilor proprietarilor de saloane de înfrumusețare pe web.

Expand Down Expand Up @@ -361,4 +372,14 @@ Doc007: În prezent, aplicația acceptă o singură afacere. Asistența multi-bu

Doc008 href: Utilizatorii aplicației, inclusiv clienți, angajați și administratori, pot fi înregistrați prin intermediul formularului <a href=#{href}>„Înregistrare”</a>.

Doc009 href: De asemenea, utilizatorii pot fi gestionați de administratori în secțiunea <a href=#{href}>„Utilizatori”</a> din grupul „Date”.
Doc009 href: De asemenea, utilizatorii pot fi gestionați de administratori în secțiunea <a href=#{href}>„Utilizatori”</a> din grupul „Date”.

Doc010: Un utilizator înregistrat poate avea mai multe roluri în același timp.

Doc011: Un administrator poate atribui rolul „Administrator” oricărui alt utilizator înregistrat. Rolul de „Administrator” este necesar pentru a avea acces la orice secțiune a grupului „Date”. Adică, gestionați orice date ale aplicației.

Doc012: Un administrator poate atribui rolul „Analist” oricărui alt utilizator înregistrat. Rolul „Analist” este necesar pentru a avea acces la orice secțiune a grupului „Analiza”. Adică pentru a genera rapoarte analitice.

Doc013: Orice utilizator care este înregistrat și ca membru al personalului are rolul „Angajat”. Un utilizator cu rolul „Angajat” are acces la coada de solicitări de servicii.

Doc014: Toți utilizatorii pot deveni clienți prin simpla înregistrare și utilizarea serviciilor oferite.
23 changes: 22 additions & 1 deletion messages/ru.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
OnlyAdminisHaveAccess: Только администраторы могут управлять этими данными
AuthorizationRequired: Требуется авторизация
OnlyAnalystsHaveAccess: Доступ к аналитическим отчетам имеют только аналитики
LoginAsAdminToContinue: Пожалуйста, войдите в систему как администратор, чтобы продолжить
LoginAsAnalystToContinue: Пожалуйста, войдите в систему как аналитик, чтобы продолжить
Analyst: Аналитик
NoRequestsFoundForThisDay: Запросов на этот день не найдено
LoginAsEmployeeToContinue: Пожалуйста, войдите в систему как сотрудник, чтобы продолжить
LoginToContinue: Пожалуйста, войдите, чтобы продолжить
Expand Down Expand Up @@ -330,6 +336,11 @@ AppName: Салон
MetaKeywords: салон, красоты, приложение
MetaDescription: Приложение Салон Красоты


DemoSampleOne: Нажмите на значок
DemoSampleTwo: , чтобы получить список демонстрационных учетных записей пользователей


Documentation: Документация
Doc001 hrefHome: Приложение <a href=#{hrefHome}>«Салон»</a> предоставляет возможность публиковать и рекламировать услуги владельцев салонов красоты в сети.

Expand Down Expand Up @@ -361,4 +372,14 @@ Doc007: В настоящее время приложение поддержив

Doc008 href: Пользователи приложения, включая клиентов, сотрудников и администраторов, могут быть зарегистрированы через форму <a href=#{href}>«Регистрация»</a>.

Doc009 href: Также управлять пользователями администраторы могут в разделе <a href=#{href}>«Пользователи»</a> группы «Данные».
Doc009 href: Также управлять пользователями администраторы могут в разделе <a href=#{href}>«Пользователи»</a> группы «Данные».

Doc010: Зарегистрированный пользователь может иметь несколько ролей одновременно.

Doc011: Администратор может назначить роль «Администратор» любому другому зарегистрированному пользователю. Роль «Администратор» необходима для того, чтобы иметь доступ к любому разделу группы «Данные». То есть управлять любыми данными приложения.

Doc012: Администратор может назначить роль «Аналитик» любому другому зарегистрированному пользователю. Роль «Аналитик» необходима для того, чтобы иметь доступ к любому разделу группы «Аналитика». То есть формировать аналитические отчеты.

Doc013: Любой пользователь, который также зарегистрирован как сотрудник, имеет роль «Сотрудник». Пользователь с ролью «Сотрудник» имеет доступ к очереди запросов на обслуживание.

Doc014: Все пользователи могут стать клиентами, просто зарегистрировавшись и воспользовавшись предлагаемыми услугами.
24 changes: 15 additions & 9 deletions src/Admin/Business.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ import Model
)
, BrandId
)

import Settings (widgetFile)
import Settings.StaticFiles (img_add_photo_alternate_FILL0_wght400_GRAD0_opsz48_svg)
import Menu (menu)
Expand Down Expand Up @@ -215,7 +215,7 @@ postBrandDeleteR :: BusinessId -> BrandId -> Handler Html
postBrandDeleteR bid rid = do
runDB $ delete $ void $ do
x <- from (table @Brand)
where_ $ x ^. BrandId ==. val rid
where_ $ x ^. BrandId ==. val rid
addMessageI "info" MsgRecordDeleted
redirect $ AdminR $ BrandR bid

Expand All @@ -229,7 +229,7 @@ postBrandEditR bid rid = do
(ico,icoMime) <- (,fileContentType <$> mico) <$> mapM fileSourceByteString mico
runDB $ update $ \x -> do
set x [ BrandMarkWidth =. val (brandMarkWidth r)
, BrandMarkHeight =. val (brandMarkHeight r)
, BrandMarkHeight =. val (brandMarkHeight r)
, BrandName =. val (brandName r)
, BrandStrapline =. val (brandStrapline r)
, BrandMore =. val (brandMore r)
Expand Down Expand Up @@ -459,7 +459,7 @@ formContact bid e extra = do
} (contactUsLatitude . entityVal <$> e)
let r = ContactUs bid <$> htmlR <*> showAddrR <*> showScheduleR <*> showMapR <*> lonR <*> latR
let v = [whamlet|
#{extra}
#{extra}
<div.form-field>
<label.mdc-text-field.mdc-text-field--filled.mdc-text-field--textarea data-mdc-auto-init=MDCTextField
:isJust (fvErrors htmlV):.mdc-text-field--invalid>
Expand Down Expand Up @@ -512,7 +512,7 @@ $forall v <- [lonV,latV]
|]
return (r,v)
where

uniqueField = checkM uniqueContactUs htmlField

uniqueContactUs :: Html -> Handler (Either AppMessage Html)
Expand Down Expand Up @@ -552,13 +552,13 @@ getBusinessContactR bid = do
x <- from $ table @Business
return (x ^. BusinessAddr) )
_ -> return Nothing

schedule <- case info of
Just (Entity _ (ContactUs _ _ _ True _ _ _)) -> do
let groupByKey :: (Ord k) => (v -> k) -> [v] -> M.Map k [v]
groupByKey key = M.fromListWith (++) . fmap (\x -> (key x,[x]))

M.toList . groupByKey (\(Entity _ (BusinessHours _ day s e _)) -> (dayOfWeek day,(s,e))) <$> do
M.toList . groupByKey (\(Entity _ (BusinessHours _ day s e _)) -> (dayOfWeek day,(s,e))) <$> do
ymd <- (((toGregorian <$>) . unValue) =<<) <$> runDB ( selectOne ( do
x <- from $ table @BusinessHours
where_ $ x ^. BusinessHoursDayType ==. val Weekday
Expand All @@ -575,7 +575,7 @@ getBusinessContactR bid = do
_ -> return []
_ -> return []
defaultLayout $ do
setTitleI MsgContactUs
setTitleI MsgContactUs
case info of
Just (Entity _ (ContactUs _ _ _ _ True (Just lng) (Just lat))) -> do
addScriptRemote "https://api.mapbox.com/mapbox-gl-js/v2.14.1/mapbox-gl.js"
Expand Down Expand Up @@ -719,7 +719,7 @@ formAbout bid e extra = do
|]
return (r,v)
where

uniqueField = checkM uniqueAboutUs htmlField

uniqueAboutUs :: Html -> Handler (Either AppMessage Html)
Expand Down Expand Up @@ -898,7 +898,11 @@ getBusinessCalendarR bid month = do
let page = [start .. end]
let next = addMonths 1 month
let prev = addMonths (-1) month

today <- (\(y,m,_) -> YearMonth y m) . toGregorian . utctDay <$> liftIO getCurrentTime
formQuery <- newIdent
toolbarTop <- newIdent
calendarPage <- newIdent
defaultLayout $ do
setTitleI MsgBusinessDays
$(widgetFile "/admin/business/schedule/calendar/calendar")
Expand Down Expand Up @@ -1025,7 +1029,9 @@ getBusinessHoursR bid = do
month <- (\(y,m,_) -> YearMonth y m) . toGregorian . utctDay <$> liftIO getCurrentTime
setUltDestCurrent
msgs <- getMessages
formQuery <- newIdent
toolbarTop <- newIdent
buttonSort <- newIdent
fabBusinessHoursCreate <- newIdent
defaultLayout $ do
setTitleI MsgBusinessDays
Expand Down
Loading

0 comments on commit e60be58

Please sign in to comment.