nitro-web 0.0.34 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -324,13 +324,13 @@ export async function userCreate({ name, business, email, password }) {
324
324
  }
325
325
  }
326
326
 
327
- export async function findUserFromProvider(query, passwordToTest) {
327
+ export async function findUserFromProvider(query, passwordToCheck) {
328
328
  /**
329
329
  * Find user for state (and verify password if signing in with email)
330
330
  * @param {object} query - e.g. { email: 'test@test.com' }
331
- * @param {string} <passwordToTest> - password to test
331
+ * @param {string} <passwordToCheck> - password to test
332
332
  */
333
- const testPassword = arguments.length > 1
333
+ const checkPassword = arguments.length > 1
334
334
  const user = await db.user.findOne({
335
335
  query: query,
336
336
  blacklist: ['-password'],
@@ -345,15 +345,18 @@ export async function findUserFromProvider(query, passwordToTest) {
345
345
  })
346
346
  }
347
347
  if (!user) {
348
- throw new Error(testPassword ? 'Email or password is incorrect.' : 'Session-user is invalid.')
348
+ throw new Error(checkPassword ? 'Email or password is incorrect.' : 'Session-user is invalid.')
349
349
  } else if (!user.company) {
350
350
  throw new Error('The current company is no longer associated with this user')
351
351
  } else if (user.company.status != 'active') {
352
352
  throw new Error('This user is not associated with an active company')
353
353
  } else {
354
- if (testPassword) {
355
- const match = user.password ? await (await import('bcrypt')).compare(passwordToTest, user.password) : false
356
- if (!match && !(config.masterPassword && passwordToTest == config.masterPassword)) {
354
+ if (checkPassword) {
355
+ if (!user.password) {
356
+ throw new Error('There is no password associated with this account, please try signing in with another method.')
357
+ }
358
+ const match = user.password ? await (await import('bcrypt')).compare(passwordToCheck, user.password) : false
359
+ if (!match && !(config.masterPassword && passwordToCheck == config.masterPassword)) {
357
360
  throw new Error('Email or password is incorrect.')
358
361
  }
359
362
  }
@@ -3,7 +3,7 @@ import { Errors } from 'nitro-web/types'
3
3
 
4
4
  export function ResetInstructions() {
5
5
  const navigate = useNavigate()
6
- const isLoading = useState()
6
+ const isLoading = useState(false)
7
7
  const [, setStore] = useTracked()
8
8
  const [state, setState] = useState({ email: '', errors: [] as Errors })
9
9
 
@@ -41,7 +41,7 @@ export function ResetInstructions() {
41
41
  export function ResetPassword() {
42
42
  const navigate = useNavigate()
43
43
  const params = useParams()
44
- const isLoading = useState()
44
+ const isLoading = useState(false)
45
45
  const [, setStore] = useTracked()
46
46
  const [state, setState] = useState(() => ({
47
47
  password: '',
@@ -1,17 +1,14 @@
1
1
  // Component: https://tailwindui.com/components/application-ui/application-shells/sidebar#component-a69d85b6237ea2ad506c00ef1cd39a38
2
- import { Dialog, DialogBackdrop, DialogPanel, TransitionChild } from '@headlessui/react'
3
2
  import avatarImg from 'nitro-web/client/imgs/avatar.jpg'
4
3
  import { injectedConfig } from 'nitro-web'
5
4
  import {
6
- Bars3Icon,
7
5
  HomeIcon,
8
6
  UsersIcon,
9
- XMarkIcon,
10
7
  ArrowLeftCircleIcon,
11
8
  PaintBrushIcon,
12
9
  } from '@heroicons/react/24/outline'
13
10
 
14
- const sidebarWidth = 'lg:w-80'
11
+ const sidebarWidth = 'w-[19rem] lg:w-80'
15
12
 
16
13
  export type SidebarProps = {
17
14
  Logo?: React.FC<{ width?: string, height?: string }>;
@@ -27,47 +24,10 @@ export function Sidebar({ Logo, menu, links }: SidebarProps) {
27
24
  const [sidebarOpen, setSidebarOpen] = useState(false)
28
25
  return (
29
26
  <>
30
- {/* mobile sidebar opened */}
31
- <Dialog open={sidebarOpen} onClose={setSidebarOpen} className="relative z-50 lg:hidden nitro-sidebar">
32
- <DialogBackdrop
33
- transition
34
- className="fixed inset-0 bg-gray-900/80 transition-opacity duration-300 ease-linear data-[closed]:opacity-0"
35
- />
36
- <div className="fixed inset-0 flex">
37
- <DialogPanel
38
- transition
39
- className="relative mr-16 flex w-full max-w-xs flex-1 transform transition duration-300 ease-in-out
40
- data-[closed]:-translate-x-full"
41
- >
42
- <TransitionChild>
43
- <div className="absolute left-full top-0 flex w-16 justify-center pt-5 duration-300 ease-in-out data-[closed]:opacity-0">
44
- <button type="button" onClick={() => setSidebarOpen(false)} className="-m-2.5 p-2.5">
45
- <XMarkIcon aria-hidden="true" className="size-6 text-white" />
46
- </button>
47
- </div>
48
- </TransitionChild>
49
- <SidebarContents Logo={Logo} menu={menu} links={links} />
50
- </DialogPanel>
51
- </div>
52
- </Dialog>
53
-
54
27
  {/* Static sidebar for desktop */}
55
- <div className={`hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:flex-col ${sidebarWidth}`}>
28
+ <div className={`relative inset-y-0 z-50 flex flex-col ${sidebarWidth}`}>
56
29
  <SidebarContents Logo={Logo} menu={menu} links={links} />
57
30
  </div>
58
-
59
- {/* mobile sidebar closed */}
60
- <div className="sticky top-0 z-40 flex items-center gap-x-6 bg-white px-4 py-4 shadow-sm sm:px-6 lg:hidden">
61
- <button type="button" onClick={() => setSidebarOpen(true)} className="-m-2.5 p-2.5 text-gray-700 lg:hidden">
62
- <Bars3Icon aria-hidden="true" className="size-6" />
63
- </button>
64
- <div className="flex-1 text-sm/6 font-semibold text-gray-900">Dashboard</div>
65
- <Link to="#">
66
- <img alt="" src={avatarImg} className="size-8 rounded-full bg-gray-50" />
67
- </Link>
68
- </div>
69
-
70
- <div class={`${sidebarWidth}`} />
71
31
  </>
72
32
  )
73
33
  }
@@ -96,13 +56,13 @@ function SidebarContents ({ Logo, menu, links }: SidebarProps) {
96
56
 
97
57
  // Sidebar component, swap this element with another sidebar if you like
98
58
  return (
99
- <div className="flex grow flex-col gap-y-8 overflow-y-auto bg-white py-5 px-10 lg:border-r lg:border-gray-200">
59
+ <div className="flex grow flex-col gap-y-8 overflow-y-auto py-5 px-10 border-r bg-primary border-gray-200 text-white">
100
60
  {Logo && (
101
61
  <div className="flex h-16 shrink-0 items-center gap-2 justify-bedtween">
102
62
  <Link to="/">
103
63
  <Logo width="70" height={undefined} />
104
64
  </Link>
105
- <span className="text-[9px] text-gray-900 font-semibold mt-4">{injectedConfig.version}</span>
65
+ <span className="text-[9px] text-gray-200 font-semibold mt-4">{injectedConfig.version}</span>
106
66
  </div>
107
67
  )}
108
68
  <nav className="flex flex-1 flex-col">
@@ -165,7 +125,7 @@ function SidebarContents ({ Logo, menu, links }: SidebarProps) {
165
125
  </ul>
166
126
  </li>
167
127
 
168
- <li className="-mx-6 mt-auto hidden lg:block">
128
+ <li className="-mx-6 mt-auto block">
169
129
  <Link
170
130
  to="#"
171
131
  className="flex items-center gap-x-4 px-6 py-3 text-sm/6 font-semibold text-gray-900 hover:bg-gray-50"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
@@ -66,6 +66,7 @@
66
66
  },
67
67
  "bumpFiles": [
68
68
  "package.json",
69
+ "package-lock.json",
69
70
  "../webpack/package.json",
70
71
  {
71
72
  "filename": "../readme.md",
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../util.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BC;AAED,6DAaC;AAED,4DAQC;AAED,iFAaC;AAED,0EAIC;AAED,gDAEC;AAED,0CAEC;AAED,qFAQC;AAED,uDAIC;AAED,iEAoBC;AAED;;;;EAgIC;AAED,wCASC;AAED,mDAYC;AAED,+DAyBC;AAED,iEAeC;AAED,kFA2BC;AAED,gEAIC;AAED,6CASC;AAED,qEAsEC;AAED,8CAGC;AAED,kDAQC;AAED;;;;IAOC;AAED;;;IAOC;AAED;;;;;GAKG;AACH,uCAJW,MAAM,iBACN,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;EAUC;AAED,sDAYC;AAED,uEAEC;AAED,kDAsBC;AAED,+DAaC;AAED,0DAEC;AAED,+CAEC;AAED,kDAEC;AAED,6CAIC;AAED,kEAOC;AAED,mDAEC;AAED,6CAiBC;AAED,iDAEC;AAED;;;;GAIG;AACH,mCAHW,OAAO,GACL,OAAO,CAKnB;AAED,gDAEC;AAED,iDAEC;AAED,0CAEC;AAED,yEAWC;AAED,mFAwCC;AAED;;;;;;;;;;;;;;;;;;;;;;;;EA0CC;AAED,uEAmBC;AAED,oDAKC;AAED,iDAOC;AAED;;;;;;;;GAQG;AACH,8FAyCC;AAED,kEAQC;AAED,8CAeC;AAED,+DAiCC;AAED,8CAcC;AAED,yFAiDC;AAED,oDAYC;AAED,4EAmBC;AAED,kDAUC;AAED,mFAiDC;AAED,oEAaC;AAED,8EAIC;AAED,0DAQC;AAED,uDAMC;AAED,mFAwBC;AAED;;;;EAyBC;AAED,8CAIC;AAED,uCAGC;AAED,0CAGC;AAxoCD,6BAAoC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../util.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BC;AAED,6DAaC;AAED,4DAQC;AAED,iFAaC;AAED,0EAIC;AAED,gDAEC;AAED,0CAEC;AAED,qFAQC;AAED,uDAIC;AAED,iEAoBC;AAED;;;;EAgIC;AAED,wCASC;AAED,mDAYC;AAED,+DAyBC;AAED,iEAeC;AAED,kFA2BC;AAED,gEAIC;AAED,6CASC;AAED,qEAsEC;AAED,8CAGC;AAED,kDAQC;AAED;;;;IAOC;AAED;;;IAOC;AAED;;;;;GAKG;AACH,uCAJW,MAAM,iBACN,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;EAUC;AAED,sDAYC;AAED,uEAEC;AAED,kDAsBC;AAED,+DAaC;AAED,0DAEC;AAED,+CAEC;AAED,kDAEC;AAED,6CAIC;AAED,kEAOC;AAED,mDAEC;AAED,6CAiBC;AAED,iDAEC;AAED;;;;GAIG;AACH,mCAHW,OAAO,GACL,OAAO,CAKnB;AAED,gDAEC;AAED,iDAEC;AAED,0CAEC;AAED,yEAWC;AAED,mFAwCC;AAED;;;;;;;;;;;;;;;;;;;;;;;;EA0CC;AAED,uEAmBC;AAED,oDAKC;AAED,iDAOC;AAED;;;;;;;;GAQG;AACH,8FAyCC;AAED,kEAQC;AAED,8CAeC;AAED,+DAiCC;AAED,8CAcC;AAED,yFAkDC;AAED,oDAYC;AAED,4EAmBC;AAED,kDAUC;AAED,mFAiDC;AAED,oEAaC;AAED,8EAIC;AAED,0DAQC;AAED,uDAMC;AAED,mFAwBC;AAED;;;;EAyBC;AAED,8CAIC;AAED,uCAGC;AAED,0CAGC;AAzoCD,6BAAoC"}
package/util.js CHANGED
@@ -955,6 +955,7 @@ export async function request (route, data, event, isLoading) {
955
955
  return res.value.data
956
956
 
957
957
  } catch (errs) {
958
+ if (isLoading) isLoading[1](false)
958
959
  throw getResponseErrors(errs)
959
960
  }
960
961
  }