Skip to content

Commit

Permalink
Apply prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert committed Mar 2, 2025
1 parent a1906a0 commit e73519d
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true
isolatedModules: true,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans',
'Helvetica Neue', sans-serif;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,175 +79,175 @@ This file contains both the template and component logic for the authentication
</template>

<script lang="ts">
import { AUTH_REPOSITORY } from '@/auth/application/AuthProvider';
import type { AuthRepository } from '@/auth/domain/AuthRepository';
import type { AuthenticatedUser } from '@/auth/domain/AuthenticatedUser';
import type { LoginCredentials } from '@/auth/domain/LoginCredentials';
import { inject } from '@/injections';
import { defineComponent, onMounted, ref } from 'vue';
export default defineComponent({
name: 'AuthVue',
setup() {
const authRepository = inject(AUTH_REPOSITORY) as AuthRepository;
const isAuthenticated = ref(false);
const currentUser = ref<AuthenticatedUser | null>(null);
const username = ref('');
const password = ref('');
const checkAuth = () => {
authRepository
.authenticated()
.then(authenticated => {
isAuthenticated.value = authenticated;
if (isAuthenticated.value) {
loggedCurrentUser();
} else {
currentUser.value = null;
}
})
.catch(error => {
console.error('Error during authentication check:', error);
});
};
import { AUTH_REPOSITORY } from '@/auth/application/AuthProvider';
import type { AuthRepository } from '@/auth/domain/AuthRepository';
import type { AuthenticatedUser } from '@/auth/domain/AuthenticatedUser';
import type { LoginCredentials } from '@/auth/domain/LoginCredentials';
import { inject } from '@/injections';
import { defineComponent, onMounted, ref } from 'vue';
export default defineComponent({
name: 'AuthVue',
setup() {
const authRepository = inject(AUTH_REPOSITORY) as AuthRepository;
const isAuthenticated = ref(false);
const currentUser = ref<AuthenticatedUser | null>(null);
const username = ref('');
const password = ref('');
const checkAuth = () => {
authRepository
.authenticated()
.then(authenticated => {
isAuthenticated.value = authenticated;
if (isAuthenticated.value) {
loggedCurrentUser();
} else {
currentUser.value = null;
}
})
.catch(error => {
console.error('Error during authentication check:', error);
});
};
const loggedCurrentUser = (): void => {
authRepository
.currentUser()
.then(user => {
currentUser.value = user;
})
.catch(error => {
console.error('Error getting current user:', error);
});
};
const loggedCurrentUser = (): void => {
authRepository
.currentUser()
.then(user => {
currentUser.value = user;
})
.catch(error => {
console.error('Error getting current user:', error);
});
};
const login = () => {
const credentials: LoginCredentials = {
username: username.value,
password: password.value,
};
authRepository
.login(credentials)
.then(() => {
checkAuth();
})
.catch(error => {
console.error('Login error:', error);
});
const login = () => {
const credentials: LoginCredentials = {
username: username.value,
password: password.value,
};
const logout = () => {
authRepository
.logout()
.then(() => {
checkAuth();
})
.catch(error => {
console.error('Logout error:', error);
});
};
authRepository
.login(credentials)
.then(() => {
checkAuth();
})
.catch(error => {
console.error('Login error:', error);
});
};
onMounted(() => {
checkAuth();
});
const logout = () => {
authRepository
.logout()
.then(() => {
checkAuth();
})
.catch(error => {
console.error('Logout error:', error);
});
};
return {
isAuthenticated,
currentUser,
username,
password,
login,
logout,
};
},
});
onMounted(() => {
checkAuth();
});
return {
isAuthenticated,
currentUser,
username,
password,
login,
logout,
};
},
});
</script>

<style scoped>
.auth-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
padding: 0 20px 20px 20px;
}
.auth-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
padding: 0 20px 20px 20px;
}
.auth-form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
.auth-form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
.auth-title {
margin-bottom: 20px;
font-size: 24px;
color: #333;
}
.auth-title {
margin-bottom: 20px;
font-size: 24px;
color: #333;
}
.auth-input {
width: 100%;
padding: 12px;
margin-bottom: 20px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 16px;
transition: border-color 0.3s;
}
.auth-input {
width: 100%;
padding: 12px;
margin-bottom: 20px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 16px;
transition: border-color 0.3s;
}
.auth-input:focus {
border-color: #3b82f6;
outline: none;
}
.auth-input:focus {
border-color: #3b82f6;
outline: none;
}
.auth-btn {
background-color: #3b82f6;
color: #fff;
padding: 12px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
width: 100%;
}
.auth-btn {
background-color: #3b82f6;
color: #fff;
padding: 12px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
width: 100%;
}
.auth-btn:hover {
background-color: #2563eb;
}
.auth-btn:hover {
background-color: #2563eb;
}
.logout-btn {
background-color: #f87171;
}
.logout-btn {
background-color: #f87171;
}
.logout-btn:hover {
background-color: #ef4444;
}
.logout-btn:hover {
background-color: #ef4444;
}
.welcome {
display: flex;
flex-direction: column;
align-items: center;
background: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
.welcome {
display: flex;
flex-direction: column;
align-items: center;
background: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
.welcome p {
font-size: 18px;
margin-bottom: 20px;
}
.welcome p {
font-size: 18px;
margin-bottom: 20px;
}
</style>
```

Expand Down Expand Up @@ -548,21 +548,21 @@ export const stubAxiosInstance = (): AxiosStubInstance => {
request: {
use: sinon.stub(),
eject: sinon.stub(),
clear: sinon.stub()
clear: sinon.stub(),
},
response: {
use: sinon.stub(),
eject: sinon.stub(),
clear: sinon.stub()
}
clear: sinon.stub(),
},
},
runInterceptors: async (config: InternalAxiosRequestConfig) => {
let currentConfig = { ...config, headers: config.headers || {} };
for (const interceptor of instance.interceptors.request.use.args) {
currentConfig = await interceptor[0](currentConfig);
}
return currentConfig;
}
},
} as AxiosStubInstance;
return instance;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ public class SimpleSteps {

@Then("I get simple response with name {string} and age {int}")
public void shouldGetResponse(String name, int age) {
assertThatLastResponse()
.hasOkStatus()
.hasElement("$.name")
.withValue(name)
.and()
.hasElement("$.age")
.withValue(age);
assertThatLastResponse().hasOkStatus().hasElement("$.name").withValue(name).and().hasElement("$.age").withValue(age);
}
}

Expand Down

0 comments on commit e73519d

Please sign in to comment.