Merge remote-tracking branch 'origin/main' into main
# Conflicts: # gymboard-api/src/main/resources/application-development.properties
This commit is contained in:
commit
7583e48fb0
|
@ -1,2 +1,7 @@
|
|||
# Gymboard
|
||||
Leaderboards for your local community gym.
|
||||
|
||||
## Development
|
||||
Gymboard is comprised of a variety of components, each in its own directory, and with its own project format. Follow the instructions in the README of the respective project to set that one up.
|
||||
|
||||
A `docker-compose.yml` file is defined in this directory, and it defines a set of services that may be used by one or more services. Install docker on your system if you haven't already, and run `docker-compose up -d` to start the services.
|
||||
|
|
|
@ -12,3 +12,22 @@ services:
|
|||
environment:
|
||||
POSTGRES_USER: gymboard-api-dev
|
||||
POSTGRES_PASSWORD: testpass
|
||||
|
||||
# Database for the gymboard-cdn.
|
||||
cdn-db:
|
||||
image: postgres
|
||||
restart: always
|
||||
ports:
|
||||
- "5433:5432"
|
||||
environment:
|
||||
POSTGRES_USER: gymboard-cdn-dev
|
||||
POSTGRES_PASSWORD: testpass
|
||||
|
||||
mailhog:
|
||||
image: mailhog/mailhog
|
||||
restart: always
|
||||
expose:
|
||||
- "8025"
|
||||
ports:
|
||||
- "1025:1025" # SMTP
|
||||
- "8025:8025" # Web UI
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
|
|
|
@ -49,9 +49,11 @@ public class SecurityConfig {
|
|||
).permitAll()
|
||||
.requestMatchers(// Allow the following POST endpoints to be public.
|
||||
HttpMethod.POST,
|
||||
"/gyms/submissions",
|
||||
"/gyms/submissions/upload",
|
||||
"/auth/token"
|
||||
"/gyms/*/submissions",
|
||||
"/gyms/*/submissions/upload",
|
||||
"/auth/token",
|
||||
"/auth/register",
|
||||
"/auth/activate"
|
||||
).permitAll()
|
||||
// Everything else must be authenticated, just to be safe.
|
||||
.anyRequest().authenticated();
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package nl.andrewlalis.gymboard_api.controller;
|
||||
|
||||
import nl.andrewlalis.gymboard_api.controller.dto.TokenCredentials;
|
||||
import nl.andrewlalis.gymboard_api.controller.dto.TokenResponse;
|
||||
import nl.andrewlalis.gymboard_api.controller.dto.UserResponse;
|
||||
import nl.andrewlalis.gymboard_api.controller.dto.*;
|
||||
import nl.andrewlalis.gymboard_api.model.auth.User;
|
||||
import nl.andrewlalis.gymboard_api.service.auth.TokenService;
|
||||
import nl.andrewlalis.gymboard_api.service.auth.UserService;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -15,9 +14,35 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RestController
|
||||
public class AuthController {
|
||||
private final TokenService tokenService;
|
||||
private final UserService userService;
|
||||
|
||||
public AuthController(TokenService tokenService) {
|
||||
public AuthController(TokenService tokenService, UserService userService) {
|
||||
this.tokenService = tokenService;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Endpoint for registering a new user in the system. <strong>This is a
|
||||
* public endpoint.</strong> If the user is successfully created, an email
|
||||
* will be sent to them with a link for activating the account.
|
||||
* @param payload The payload.
|
||||
* @return The created user.
|
||||
*/
|
||||
@PostMapping(path = "/auth/register")
|
||||
public UserResponse registerNewUser(@RequestBody UserCreationPayload payload) {
|
||||
return userService.createUser(payload, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Endpoint for activating a new user via an activation code. <strong>This
|
||||
* is a public endpoint.</strong> If the code is recent (within 24 hours)
|
||||
* and the user exists, then they'll be activated and able to log in.
|
||||
* @param payload The payload containing the activation code.
|
||||
* @return The activated user.
|
||||
*/
|
||||
@PostMapping(path = "/auth/activate")
|
||||
public UserResponse activateUser(@RequestBody UserActivationPayload payload) {
|
||||
return userService.activateUser(payload);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package nl.andrewlalis.gymboard_api.controller.dto;
|
||||
|
||||
public record UserActivationPayload(String code) {}
|
|
@ -0,0 +1,12 @@
|
|||
package nl.andrewlalis.gymboard_api.dao.auth;
|
||||
|
||||
import nl.andrewlalis.gymboard_api.model.auth.UserActivationCode;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface UserActivationCodeRepository extends JpaRepository<UserActivationCode, Long> {
|
||||
Optional<UserActivationCode> findByCode(String code);
|
||||
}
|
|
@ -144,7 +144,7 @@ public class SampleDataLoader implements ApplicationListener<ContextRefreshedEve
|
|||
String[] roleNames = record.get(3).split("\\s*\\|\\s*");
|
||||
|
||||
UserCreationPayload payload = new UserCreationPayload(email, password, name);
|
||||
var resp = userService.createUser(payload);
|
||||
var resp = userService.createUser(payload, false);
|
||||
User user = userRepository.findByIdWithRoles(resp.id()).orElseThrow();
|
||||
for (var roleName : roleNames) {
|
||||
if (roleName.isBlank()) continue;
|
||||
|
|
|
@ -60,6 +60,10 @@ public class User {
|
|||
return activated;
|
||||
}
|
||||
|
||||
public void setActivated(boolean activated) {
|
||||
this.activated = activated;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package nl.andrewlalis.gymboard_api.model.auth;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "auth_user_activation_code")
|
||||
public class UserActivationCode {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@CreationTimestamp
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
private User user;
|
||||
|
||||
@Column(nullable = false, unique = true, updatable = false, length = 127)
|
||||
private String code;
|
||||
|
||||
public UserActivationCode() {}
|
||||
|
||||
public UserActivationCode(User user, String code) {
|
||||
this.user = user;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
|
@ -1,26 +1,54 @@
|
|||
package nl.andrewlalis.gymboard_api.service.auth;
|
||||
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import nl.andrewlalis.gymboard_api.controller.dto.UserActivationPayload;
|
||||
import nl.andrewlalis.gymboard_api.controller.dto.UserCreationPayload;
|
||||
import nl.andrewlalis.gymboard_api.controller.dto.UserResponse;
|
||||
import nl.andrewlalis.gymboard_api.dao.auth.UserActivationCodeRepository;
|
||||
import nl.andrewlalis.gymboard_api.dao.auth.UserRepository;
|
||||
import nl.andrewlalis.gymboard_api.model.auth.User;
|
||||
import nl.andrewlalis.gymboard_api.model.auth.UserActivationCode;
|
||||
import nl.andrewlalis.gymboard_api.util.ULID;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Random;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
private static final Logger log = LoggerFactory.getLogger(UserService.class);
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final UserActivationCodeRepository activationCodeRepository;
|
||||
private final ULID ulid;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final JavaMailSender mailSender;
|
||||
|
||||
public UserService(UserRepository userRepository, ULID ulid, PasswordEncoder passwordEncoder) {
|
||||
@Value("${app.web-origin}")
|
||||
private String webOrigin;
|
||||
|
||||
public UserService(
|
||||
UserRepository userRepository,
|
||||
UserActivationCodeRepository activationCodeRepository, ULID ulid,
|
||||
PasswordEncoder passwordEncoder,
|
||||
JavaMailSender mailSender
|
||||
) {
|
||||
this.userRepository = userRepository;
|
||||
this.activationCodeRepository = activationCodeRepository;
|
||||
this.ulid = ulid;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
this.mailSender = mailSender;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
|
@ -31,15 +59,71 @@ public class UserService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public UserResponse createUser(UserCreationPayload payload) {
|
||||
public UserResponse createUser(UserCreationPayload payload, boolean requireActivation) {
|
||||
// TODO: Validate user payload.
|
||||
User user = userRepository.save(new User(
|
||||
ulid.nextULID(),
|
||||
true, // TODO: Change this to false once email activation is in.
|
||||
!requireActivation,
|
||||
payload.email(),
|
||||
passwordEncoder.encode(payload.password()),
|
||||
payload.name()
|
||||
));
|
||||
if (requireActivation) {
|
||||
generateAndSendActivationCode(user);
|
||||
}
|
||||
return new UserResponse(user);
|
||||
}
|
||||
|
||||
private void generateAndSendActivationCode(User user) {
|
||||
Random random = new SecureRandom();
|
||||
StringBuilder sb = new StringBuilder(127);
|
||||
final String alphabet = "bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ23456789";
|
||||
for (int i = 0; i < 127; i++) {
|
||||
sb.append(alphabet.charAt(random.nextInt(alphabet.length())));
|
||||
}
|
||||
String rawCode = sb.toString();
|
||||
UserActivationCode activationCode = activationCodeRepository.save(new UserActivationCode(user, rawCode));
|
||||
// Send email.
|
||||
String activationLink = webOrigin + "/activate?code=" + activationCode.getCode();
|
||||
String emailContent = String.format(
|
||||
"""
|
||||
<p>Hello %s,</p>
|
||||
|
||||
<p>
|
||||
Thank you for registering a new account at Gymboard!
|
||||
</p>
|
||||
<p>
|
||||
Please click <a href="%s">here</a> to activate your account.
|
||||
</p>
|
||||
""",
|
||||
user.getName(),
|
||||
activationLink
|
||||
);
|
||||
MimeMessage msg = mailSender.createMimeMessage();
|
||||
try {
|
||||
MimeMessageHelper helper = new MimeMessageHelper(msg, "UTF-8");
|
||||
helper.setFrom("Gymboard <noreply@gymboard.io>");
|
||||
helper.setSubject("Activate Your Gymboard Account");
|
||||
helper.setTo(user.getEmail());
|
||||
helper.setText(emailContent, true);
|
||||
mailSender.send(msg);
|
||||
} catch (MessagingException e) {
|
||||
log.error("Error sending user activation email.", e);
|
||||
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public UserResponse activateUser(UserActivationPayload payload) {
|
||||
UserActivationCode activationCode = activationCodeRepository.findByCode(payload.code())
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST));
|
||||
LocalDateTime cutoff = LocalDateTime.now().minusDays(1);
|
||||
if (activationCode.getCreatedAt().isBefore(cutoff)) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Code is expired.");
|
||||
}
|
||||
User user = activationCode.getUser();
|
||||
user.setActivated(true);
|
||||
userRepository.save(user);
|
||||
return new UserResponse(user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,5 +9,10 @@ spring.jpa.show-sql=false
|
|||
spring.task.execution.pool.core-size=3
|
||||
spring.task.execution.pool.max-size=10
|
||||
|
||||
spring.mail.host=127.0.0.1
|
||||
spring.mail.port=1025
|
||||
spring.mail.protocol=smtp
|
||||
spring.mail.properties.mail.smtp.timeout=10000
|
||||
|
||||
app.auth.private-key-location=./private_key.der
|
||||
app.web-origin=http://localhost:9000
|
||||
|
|
|
@ -111,7 +111,9 @@ module.exports = configure(function (ctx) {
|
|||
// directives: [],
|
||||
|
||||
// Quasar plugins
|
||||
plugins: [],
|
||||
plugins: [
|
||||
'Notify'
|
||||
],
|
||||
},
|
||||
|
||||
// animations: 'all', // --- includes all animations
|
||||
|
|
|
@ -14,6 +14,12 @@ export interface TokenCredentials {
|
|||
password: string;
|
||||
}
|
||||
|
||||
export interface UserCreationPayload {
|
||||
name: string;
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
class AuthModule {
|
||||
private static readonly TOKEN_REFRESH_INTERVAL_MS = 30000;
|
||||
|
||||
|
@ -35,6 +41,16 @@ class AuthModule {
|
|||
clearTimeout(this.tokenRefreshTimer);
|
||||
}
|
||||
|
||||
public async register(payload: UserCreationPayload) {
|
||||
const response = await api.post('/auth/register', payload);
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
public async activateUser(code: string): Promise<User> {
|
||||
const response = await api.post('/auth/activate', {code: code});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
private async fetchNewToken(credentials: TokenCredentials): Promise<string> {
|
||||
const response = await api.post('/auth/token', credentials);
|
||||
return response.data.token;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { boot } from 'quasar/wrappers';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import {boot} from 'quasar/wrappers';
|
||||
import {createI18n} from 'vue-i18n';
|
||||
|
||||
import messages from 'src/i18n';
|
||||
|
||||
|
@ -28,6 +28,17 @@ export default boot(({ app }) => {
|
|||
messages,
|
||||
});
|
||||
|
||||
// Set the locale to the preferred locale, if possible.
|
||||
const userLocale = window.navigator.language;
|
||||
if (userLocale === 'nl-NL') {
|
||||
i18n.global.locale.value = userLocale;
|
||||
} else {
|
||||
i18n.global.locale.value = 'en-US';
|
||||
}
|
||||
|
||||
// Temporary override if you want to test a particular locale.
|
||||
i18n.global.locale.value = 'nl-NL';
|
||||
|
||||
// Set i18n instance on app
|
||||
app.use(i18n);
|
||||
});
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
<q-list>
|
||||
<q-item clickable v-close-popup @click="api.auth.logout(authStore)">
|
||||
<q-item-section>
|
||||
<q-item-label>Log out</q-item-label>
|
||||
<q-item-label>{{ $t('accountMenuItem.logOut') }}</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-btn-dropdown>
|
||||
<q-btn
|
||||
color="primary"
|
||||
:label="$t('Login')"
|
||||
:label="$t('accountMenuItem.logIn')"
|
||||
v-if="!authStore.loggedIn"
|
||||
no-caps
|
||||
icon="person"
|
||||
to="/login"
|
||||
@click="goToLoginPage"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -29,8 +29,20 @@
|
|||
<script setup lang="ts">
|
||||
import { useAuthStore } from 'stores/auth-store';
|
||||
import api from 'src/api/main';
|
||||
import {useRoute, useRouter} from 'vue-router';
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
async function goToLoginPage() {
|
||||
await router.push({
|
||||
path: '/login',
|
||||
query: {
|
||||
next: encodeURIComponent(route.path)
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
|
|
@ -6,13 +6,11 @@ width for smaller screens.
|
|||
Use this as the root component for any pages you create.
|
||||
-->
|
||||
<template>
|
||||
<q-page>
|
||||
<div class="row justify-center">
|
||||
<div class="col-xs-12 col-md-6 q-px-sm">
|
||||
<slot>
|
||||
<p>Page content</p>
|
||||
</slot>
|
||||
</div>
|
||||
<div class="row justify-center">
|
||||
<div class="col-xs-12 col-md-6 q-px-sm">
|
||||
<slot>
|
||||
<p>Page content</p>
|
||||
</slot>
|
||||
</div>
|
||||
</q-page>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -3,6 +3,21 @@ export default {
|
|||
language: 'Language',
|
||||
pages: 'Pages',
|
||||
},
|
||||
registerPage: {
|
||||
title: 'Create a Gymboard Account',
|
||||
name: 'Name',
|
||||
email: 'Email',
|
||||
password: 'Password',
|
||||
register: 'Register',
|
||||
error: 'An error occurred.'
|
||||
},
|
||||
loginPage: {
|
||||
title: 'Login to Gymboard',
|
||||
email: 'Email',
|
||||
password: 'Password',
|
||||
logIn: 'Log in',
|
||||
createAccount: 'Create an account'
|
||||
},
|
||||
indexPage: {
|
||||
searchHint: 'Search for a Gym',
|
||||
},
|
||||
|
@ -24,4 +39,8 @@ export default {
|
|||
submit: 'Submit',
|
||||
},
|
||||
},
|
||||
accountMenuItem: {
|
||||
logIn: 'Login',
|
||||
logOut: 'Log out'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,6 +3,21 @@ export default {
|
|||
language: 'Taal',
|
||||
pages: "Pagina's",
|
||||
},
|
||||
registerPage: {
|
||||
title: 'Maak een nieuwe Gymboard account aan',
|
||||
name: 'Naam',
|
||||
email: 'E-mail',
|
||||
password: 'Wachtwoord',
|
||||
register: 'Registreren',
|
||||
error: 'Er is een fout opgetreden.'
|
||||
},
|
||||
loginPage: {
|
||||
title: 'Inloggen bij Gymboard',
|
||||
email: 'E-mail',
|
||||
password: 'Wachtwoord',
|
||||
logIn: 'Inloggen',
|
||||
createAccount: 'Account aanmaken'
|
||||
},
|
||||
indexPage: {
|
||||
searchHint: 'Zoek een sportschool',
|
||||
},
|
||||
|
@ -24,4 +39,8 @@ export default {
|
|||
submit: 'Sturen',
|
||||
},
|
||||
},
|
||||
accountMenuItem: {
|
||||
logIn: 'Inloggen',
|
||||
logOut: 'Uitloggen'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
<template>
|
||||
<StandardCenteredPage>
|
||||
<q-input
|
||||
v-model="searchQuery"
|
||||
:label="$t('indexPage.searchHint')"
|
||||
clearable
|
||||
:loading="searchBarLoadingState"
|
||||
@update:modelValue="onSearchQueryUpdated"
|
||||
class="q-mt-lg"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
<q-list>
|
||||
<GymSearchResultListItem
|
||||
v-for="result in searchResults"
|
||||
:gym="result"
|
||||
:key="result.compoundId"
|
||||
/>
|
||||
</q-list>
|
||||
</StandardCenteredPage>
|
||||
<q-page>
|
||||
<StandardCenteredPage>
|
||||
<q-input
|
||||
v-model="searchQuery"
|
||||
:label="$t('indexPage.searchHint')"
|
||||
clearable
|
||||
:loading="searchBarLoadingState"
|
||||
@update:modelValue="onSearchQueryUpdated"
|
||||
class="q-mt-lg"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
<q-list>
|
||||
<GymSearchResultListItem
|
||||
v-for="result in searchResults"
|
||||
:gym="result"
|
||||
:key="result.compoundId"
|
||||
/>
|
||||
</q-list>
|
||||
</StandardCenteredPage>
|
||||
</q-page>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
<template>
|
||||
<StandardCenteredPage>
|
||||
<h3>Testing Page</h3>
|
||||
<p>
|
||||
Use this page to test new functionality, before adding it to the main app.
|
||||
This page should be hidden on production.
|
||||
</p>
|
||||
<div style="border: 3px solid red">
|
||||
<h4>Auth Test</h4>
|
||||
<q-btn label="Do auth" @click="doAuth()" />
|
||||
<q-btn label="Logout" @click="api.auth.logout(authStore)" />
|
||||
</div>
|
||||
</StandardCenteredPage>
|
||||
<q-page>
|
||||
<StandardCenteredPage>
|
||||
<h3>Testing Page</h3>
|
||||
<p>
|
||||
Use this page to test new functionality, before adding it to the main app.
|
||||
This page should be hidden on production.
|
||||
</p>
|
||||
<div style="border: 3px solid red">
|
||||
<h4>Auth Test</h4>
|
||||
<q-btn label="Do auth" @click="doAuth()" />
|
||||
<q-btn label="Logout" @click="api.auth.logout(authStore)" />
|
||||
</div>
|
||||
</StandardCenteredPage>
|
||||
</q-page>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<template>
|
||||
<StandardCenteredPage>
|
||||
<h3 class="text-center">{{ statusText }}</h3>
|
||||
</StandardCenteredPage>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import StandardCenteredPage from 'components/StandardCenteredPage.vue';
|
||||
import {onMounted, ref} from 'vue';
|
||||
import {useRoute, useRouter} from 'vue-router';
|
||||
import api from 'src/api/main';
|
||||
import {sleep} from 'src/utils';
|
||||
import {useI18n} from 'vue-i18n';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const t = useI18n().t;
|
||||
|
||||
const statusText = ref('');
|
||||
statusText.value = t('activationPage.activating');
|
||||
|
||||
onMounted(async () => {
|
||||
await sleep(500);
|
||||
const code = route.query.code as string;
|
||||
try {
|
||||
const user = api.auth.activateUser(code);
|
||||
statusText.value = t('activationPage.success');
|
||||
console.log(user);
|
||||
await sleep(2000);
|
||||
await router.replace('/login');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
statusText.value = t('activationPage.failure');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -0,0 +1,82 @@
|
|||
<template>
|
||||
<StandardCenteredPage>
|
||||
<h3 class="text-center">{{ $t('loginPage.title') }}</h3>
|
||||
<q-form @submit="tryLogin" @reset="resetLogin">
|
||||
<SlimForm>
|
||||
<div class="row">
|
||||
<q-input
|
||||
:label="$t('loginPage.email')"
|
||||
v-model="loginModel.email"
|
||||
type="email"
|
||||
class="col-12"
|
||||
/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-input
|
||||
:label="$t('loginPage.password')"
|
||||
v-model="loginModel.password"
|
||||
:type="passwordVisible ? 'text' : 'password'"
|
||||
class="col-12"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
:name="passwordVisible ? 'visibility' : 'visibility_off'"
|
||||
class="cursor-pointer"
|
||||
@click="passwordVisible = !passwordVisible"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-btn type="submit" :label="$t('loginPage.logIn')" color="primary" class="q-mt-md col-12" no-caps/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<router-link
|
||||
:to="{ path: '/register', query: route.query.next ? { next: route.query.next } : {} }"
|
||||
class="q-mt-md text-primary text-center col-12"
|
||||
>
|
||||
{{ $t('loginPage.createAccount') }}
|
||||
</router-link>
|
||||
</div>
|
||||
</SlimForm>
|
||||
</q-form>
|
||||
</StandardCenteredPage>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import StandardCenteredPage from 'components/StandardCenteredPage.vue';
|
||||
import SlimForm from 'components/SlimForm.vue';
|
||||
import {ref} from 'vue';
|
||||
import api from 'src/api/main';
|
||||
import {useAuthStore} from 'stores/auth-store';
|
||||
import {useRoute, useRouter} from 'vue-router';
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const loginModel = ref({
|
||||
email: '',
|
||||
password: ''
|
||||
});
|
||||
const passwordVisible = ref(false);
|
||||
|
||||
async function tryLogin() {
|
||||
try {
|
||||
await api.auth.login(authStore, loginModel.value);
|
||||
const dest = route.query.next ? decodeURIComponent(route.query.next as string) : '/';
|
||||
await router.push(dest);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
function resetLogin() {
|
||||
loginModel.value.email = '';
|
||||
loginModel.value.password = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -0,0 +1,94 @@
|
|||
<template>
|
||||
<StandardCenteredPage>
|
||||
<h3 class="text-center">{{ $t('registerPage.title') }}</h3>
|
||||
<q-form @submit="tryRegister" @reset="resetForm">
|
||||
<SlimForm>
|
||||
<div class="row">
|
||||
<q-input
|
||||
:label="$t('registerPage.name')"
|
||||
v-model="registerModel.name"
|
||||
type="text"
|
||||
class="col-12"
|
||||
/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-input
|
||||
:label="$t('registerPage.email')"
|
||||
v-model="registerModel.email"
|
||||
type="email"
|
||||
class="col-12"
|
||||
/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-input
|
||||
:label="$t('registerPage.password')"
|
||||
v-model="registerModel.password"
|
||||
:type="passwordVisible ? 'text' : 'password'"
|
||||
class="col-12"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
:name="passwordVisible ? 'visibility' : 'visibility_off'"
|
||||
class="cursor-pointer"
|
||||
@click="passwordVisible = !passwordVisible"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-btn
|
||||
type="submit"
|
||||
:label="$t('registerPage.register')"
|
||||
color="primary"
|
||||
class="q-mt-md col-12"
|
||||
no-caps
|
||||
/>
|
||||
</div>
|
||||
</SlimForm>
|
||||
</q-form>
|
||||
</StandardCenteredPage>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import SlimForm from 'components/SlimForm.vue';
|
||||
import StandardCenteredPage from 'components/StandardCenteredPage.vue';
|
||||
import api from 'src/api/main';
|
||||
import {useRouter} from 'vue-router';
|
||||
import {ref} from 'vue';
|
||||
import {useQuasar} from 'quasar';
|
||||
import {useI18n} from 'vue-i18n';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const registerModel = ref({
|
||||
name: '',
|
||||
email: '',
|
||||
password: ''
|
||||
});
|
||||
const passwordVisible = ref(false);
|
||||
|
||||
const t = useI18n().t;
|
||||
const quasar = useQuasar();
|
||||
|
||||
async function tryRegister() {
|
||||
try {
|
||||
await api.auth.register(registerModel.value);
|
||||
await router.push('/register/success');
|
||||
} catch (error) {
|
||||
quasar.notify({
|
||||
message: t('registerPage.error'),
|
||||
type: 'negative'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
registerModel.value.name = '';
|
||||
registerModel.value.email = '';
|
||||
registerModel.value.password = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -0,0 +1,15 @@
|
|||
<template>
|
||||
<StandardCenteredPage>
|
||||
<h3 class="text-center">{{ $t('registrationSuccessPage.title') }}</h3>
|
||||
<p>Check your email for the link to activate your account.</p>
|
||||
<p>You may safely close this page.</p>
|
||||
</StandardCenteredPage>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import StandardCenteredPage from 'components/StandardCenteredPage.vue';
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -1,25 +1,27 @@
|
|||
<template>
|
||||
<StandardCenteredPage v-if="gym">
|
||||
<h3 class="q-my-md text-center">{{ gym.displayName }}</h3>
|
||||
<q-btn-group spread square push>
|
||||
<q-btn
|
||||
:label="$t('gymPage.home')"
|
||||
:to="getGymRoute(gym)"
|
||||
:color="homePageSelected ? 'primary' : 'secondary'"
|
||||
/>
|
||||
<q-btn
|
||||
:label="$t('gymPage.submit')"
|
||||
:to="getGymRoute(gym) + '/submit'"
|
||||
:color="submitPageSelected ? 'primary' : 'secondary'"
|
||||
/>
|
||||
<q-btn
|
||||
:label="$t('gymPage.leaderboard')"
|
||||
:to="getGymRoute(gym) + '/leaderboard'"
|
||||
:color="leaderboardPageSelected ? 'primary' : 'secondary'"
|
||||
/>
|
||||
</q-btn-group>
|
||||
<router-view />
|
||||
</StandardCenteredPage>
|
||||
<q-page>
|
||||
<StandardCenteredPage v-if="gym">
|
||||
<h3 class="q-my-md text-center">{{ gym.displayName }}</h3>
|
||||
<q-btn-group spread square push>
|
||||
<q-btn
|
||||
:label="$t('gymPage.home')"
|
||||
:to="getGymRoute(gym)"
|
||||
:color="homePageSelected ? 'primary' : 'secondary'"
|
||||
/>
|
||||
<q-btn
|
||||
:label="$t('gymPage.submit')"
|
||||
:to="getGymRoute(gym) + '/submit'"
|
||||
:color="submitPageSelected ? 'primary' : 'secondary'"
|
||||
/>
|
||||
<q-btn
|
||||
:label="$t('gymPage.leaderboard')"
|
||||
:to="getGymRoute(gym) + '/leaderboard'"
|
||||
:color="leaderboardPageSelected ? 'primary' : 'secondary'"
|
||||
/>
|
||||
</q-btn-group>
|
||||
<router-view />
|
||||
</StandardCenteredPage>
|
||||
</q-page>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
|
|
@ -7,8 +7,19 @@ import GymSubmissionPage from 'pages/gym/GymSubmissionPage.vue';
|
|||
import GymHomePage from 'pages/gym/GymHomePage.vue';
|
||||
import GymLeaderboardsPage from 'pages/gym/GymLeaderboardsPage.vue';
|
||||
import TestingPage from 'pages/TestingPage.vue';
|
||||
import LoginPage from 'pages/auth/LoginPage.vue';
|
||||
import RegisterPage from "pages/auth/RegisterPage.vue";
|
||||
import RegistrationSuccessPage from "pages/auth/RegistrationSuccessPage.vue";
|
||||
import ActivationPage from "pages/auth/ActivationPage.vue";
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
// Auth-related pages, which live outside the main layout.
|
||||
{ path: '/login', component: LoginPage },
|
||||
{ path: '/register', component: RegisterPage },
|
||||
{ path: '/register/success', component: RegistrationSuccessPage },
|
||||
{ path: '/activate', component: ActivationPage },
|
||||
|
||||
// Main app:
|
||||
{
|
||||
path: '/',
|
||||
component: MainLayout,
|
||||
|
|
|
@ -1,15 +1,33 @@
|
|||
.dub
|
||||
docs.json
|
||||
__dummy.html
|
||||
docs/
|
||||
/gymboard-cdn
|
||||
gymboard-cdn.so
|
||||
gymboard-cdn.dylib
|
||||
gymboard-cdn.dll
|
||||
gymboard-cdn.a
|
||||
gymboard-cdn.lib
|
||||
gymboard-cdn-test-*
|
||||
*.exe
|
||||
*.o
|
||||
*.obj
|
||||
*.lst
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
|
|
@ -0,0 +1,2 @@
|
|||
# Gymboard CDN
|
||||
A content delivery and management system for Gymboard, which exposes endpoints for uploading and fetching content.
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"authors": [
|
||||
"Andrew Lalis"
|
||||
],
|
||||
"copyright": "Copyright © 2023, Andrew Lalis",
|
||||
"dependencies": {
|
||||
"handy-httpd": "~>4.0.2"
|
||||
},
|
||||
"description": "Content delivery network for Gymboard.",
|
||||
"license": "proprietary",
|
||||
"name": "gymboard-cdn"
|
||||
}
|
|
@ -0,0 +1,316 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`\\unset -f command; \\command -v java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
|
@ -0,0 +1,188 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>nl.andrewlalis</groupId>
|
||||
<artifactId>gymboard-cdn</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>gymboard-cdn</name>
|
||||
<description>Content management and delivery for Gymboard</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
import std.stdio;
|
||||
|
||||
void main()
|
||||
{
|
||||
writeln("Edit source/app.d to start your project.");
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package nl.andrewlalis.gymboardcdn;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
|
||||
@Configuration
|
||||
public class Config {
|
||||
@Value("${app.web-origin}")
|
||||
private String webOrigin;
|
||||
|
||||
/**
|
||||
* Defines the CORS configuration for this API, which is to say that we
|
||||
* allow cross-origin requests ONLY from the web app for the vast majority
|
||||
* of endpoints.
|
||||
* @return The CORS configuration source.
|
||||
*/
|
||||
@Bean
|
||||
@Order(1)
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
final CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowCredentials(true);
|
||||
// Don't do this in production, use a proper list of allowed origins
|
||||
config.addAllowedOriginPattern(webOrigin);
|
||||
config.addAllowedHeader("*");
|
||||
config.addAllowedMethod("*");
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return source;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package nl.andrewlalis.gymboardcdn;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class GymboardCdnApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GymboardCdnApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package nl.andrewlalis.gymboardcdn;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
public class UploadController {
|
||||
@PostMapping(path = "/uploads", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public void uploadContent(@RequestParam MultipartFile file) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package nl.andrewlalis.gymboardcdn;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UploadService {
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
server.port=8082
|
||||
|
||||
app.web-origin=http://localhost:9000
|
|
@ -0,0 +1,4 @@
|
|||
# TODO: Find a better way than dumping files into memory.
|
||||
spring.servlet.multipart.enabled=true
|
||||
spring.servlet.multipart.max-file-size=1GB
|
||||
spring.servlet.multipart.max-request-size=2GB
|
|
@ -0,0 +1,13 @@
|
|||
package nl.andrewlalis.gymboardcdn;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class GymboardCdnApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue