diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7c974e9..93ceac1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,9 +29,11 @@ jobs: - run: npx nx affected -t e2e env: - VITE_MOCK_WALLET_PRIVATE_KEY: ${{ secrets.MOCK_WALLET_PRIVATE_KEY }} - VITE_INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }} + # thest are only for testing, DO NOT USE IT FOR OTHER PURPOSE!! + VITE_MOCK_WALLET_PRIVATE_KEY: '0x8b806ec6cc2cbc6f75e1e0a0b020dba4d02f1a8578b9a8e2fb1f53f5a1c83e99' + VITE_INFURA_PROJECT_ID: '25e33bb59b0b4803813c8f238cceb14e' acceptance: + if: ${{ false }} runs-on: ubuntu-latest continue-on-error: true steps: diff --git a/apps/server/src/national/national.module.ts b/apps/server/src/national/national.module.ts index ce9a4c2..a736acd 100644 --- a/apps/server/src/national/national.module.ts +++ b/apps/server/src/national/national.module.ts @@ -13,7 +13,7 @@ import { JwtStrategy } from './jwt.strategy'; imports: [ JwtModule.register({ secret: jwtConstants.secret, - signOptions: { expiresIn: '60s' }, + signOptions: { expiresIn: '7d' }, }), UsersModule, PassportModule, diff --git a/apps/web/src/pages/Login.tsx b/apps/web/src/pages/Login.tsx index ce2dff6..e6bb3b2 100644 --- a/apps/web/src/pages/Login.tsx +++ b/apps/web/src/pages/Login.tsx @@ -3,7 +3,7 @@ import { ChangeEvent, useState } from 'react'; export function Login() { const [nationalId, setNationalId] = useState(''); - const { login } = useAuth(); + const { login, logout } = useAuth(); const handleTyping = (e: ChangeEvent) => { setNationalId(e.target.value); @@ -22,7 +22,8 @@ export function Login() { onChange={handleTyping} value={nationalId} /> - + {' '} + ); } diff --git a/libs/react-library/src/lib/contexts/AuthContext.tsx b/libs/react-library/src/lib/contexts/AuthContext.tsx index 37898ca..e222388 100644 --- a/libs/react-library/src/lib/contexts/AuthContext.tsx +++ b/libs/react-library/src/lib/contexts/AuthContext.tsx @@ -72,6 +72,7 @@ interface User { interface AuthContextProps { user: User | null; login: (username: string, password: string) => Promise; + logout: () => void; register: (username: string, password: string) => Promise; ethereumLogin: () => Promise; updateSemaphoreCommitment: (semaphoreCommitment: string) => Promise; @@ -129,6 +130,11 @@ export const AuthProvider: React.FC = ({ children }) => { } }; + const logout = () => { + setUser(null); + localStorage.removeItem('user'); + }; + const register = async (username: string, password: string) => { const res = await fetch('/api/auth/national/register', { method: 'POST', @@ -235,6 +241,7 @@ export const AuthProvider: React.FC = ({ children }) => { value={{ user, login, + logout, register, ethereumLogin, updateSemaphoreCommitment,