diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6f2b9a37..10d39ba9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,6 +8,7 @@ variables:
build-go:
image: golang:1.16.2
stage: build
+ only: master
script:
- go build -o goscrobble cmd/go-scrobble/*.go
artifacts:
@@ -21,6 +22,7 @@ build-go:
build-react:
image: node:15.12.0
stage: build
+ only: master
script:
- cd web
- npm install
@@ -33,6 +35,7 @@ build-react:
bundle:
image: bash:latest
stage: bundle
+ only: master
variables:
GIT_STRATEGY: none
before_script:
diff --git a/docs/changelog.md b/docs/changelog.md
index 07be997e..d92978d8 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -1,5 +1,7 @@
# 0.0.7
--Switch redux -> context.
+- Switch redux -> Context
+- Remove excess packages
+
# 0.0.6
- Fix hitting dashboard when logged out
diff --git a/internal/goscrobble/user.go b/internal/goscrobble/user.go
index 2b3fff66..c1626325 100644
--- a/internal/goscrobble/user.go
+++ b/internal/goscrobble/user.go
@@ -61,10 +61,8 @@ func createUser(req *RegisterRequest, ip net.IP) error {
// Check username is valid
if !isUsernameValid(req.Username) {
- log.Println("user is invalid")
return errors.New("Username contains invalid characters")
}
- log.Println("user is valid")
// If set an email.. validate it!
if req.Email != "" {
diff --git a/web/src/Api/index.js b/web/src/Api/index.js
index 213e5c7e..ba263584 100644
--- a/web/src/Api/index.js
+++ b/web/src/Api/index.js
@@ -24,30 +24,26 @@ export const PostLogin = (formValues) => {
jwt: response.data.token,
uuid: expandedUser.sub,
exp: expandedUser.exp,
+ username: expandedUser.username,
}
- // Set in local storage
- localStorage.setItem('user', JSON.stringify(user));
-
- // Set in context
- // setUser(user)
-
toast.success('Successfully logged in.');
- // setLoading(false)
return user;
} else {
toast.error(response.data.error ? response.data.error: 'An Unknown Error has occurred');
- // setLoading(false)
return null
}
})
+ .catch(() => {
+ return Promise.resolve();
+ });
};
export const PostRegister = (formValues) => {
- axios.post(process.env.REACT_APP_API_URL + "register", formValues)
+ return axios.post(process.env.REACT_APP_API_URL + "register", formValues)
.then((response) => {
- if (response.data.token) {
- toast.success('Successfully registered. Please sign in');
+ if (response.data.message) {
+ toast.success(response.data.message);
return Promise.resolve();
} else {
@@ -56,16 +52,8 @@ export const PostRegister = (formValues) => {
return Promise.reject();
}
})
- .error((error) => {
- const message =
- (error.response &&
- error.response.data &&
- error.response.data.message) ||
- error.message ||
- error.toString();
-
- toast.error(message ? message : 'An Unknown Error has occurred')
- return Promise.reject();
+ .catch(() => {
+ return Promise.resolve();
});
};
diff --git a/web/src/Components/Navigation.js b/web/src/Components/Navigation.js
index b1dabd78..5c3ea871 100644
--- a/web/src/Components/Navigation.js
+++ b/web/src/Components/Navigation.js
@@ -1,10 +1,10 @@
-import { React, Component } from 'react';
+import { React, useState, useContext } from 'react';
import { Navbar, NavbarBrand, Collapse, Nav, NavbarToggler, NavItem } from 'reactstrap';
-import { Link } from 'react-router-dom';
+import { Link, useLocation } from 'react-router-dom';
import logo from '../logo.png';
import './Navigation.css';
-import logout from '../Contexts/AuthContextProvider';
+import AuthContext from '../Contexts/AuthContext';
const menuItems = [
'Home',
@@ -20,178 +20,141 @@ const isMobile = () => {
return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
};
-class Navigation extends Component {
- constructor(props) {
- super(props);
- this.toggleNavbar = this.toggleNavbar.bind(this);
- this.handleLogout = this.handleLogout.bind(this);
+const Navigation = () => {
+ const location = useLocation();
- // Yeah I know you might not hit home.. but I can't get the
- // path based finder thing working on initial load :sweatsmile:
- this.state = { active: "Home", collapsed: true };
+ // Lovely hack to highlight the current page (:
+ let active = "Home"
+ if (location && location.pathname && location.pathname.length > 1) {
+ active = location.pathname.replace(/\//, "");
}
- componentDidMount() {
- const { isLoggedIn } = this.props;
- if (isLoggedIn) {
- this.setState({
- isLoggedIn: true,
- });
- }
+ let activeStyle = { color: '#FFFFFF' };
+ let { user, Logout } = useContext(AuthContext);
+ let [collapsed, setCollapsed] = useState(true);
- }
-
- _handleClick(menuItem) {
- this.setState({ active: menuItem, collapsed: !this.state.collapsed });
- }
-
- handleLogout() {
- this.dispatch(logout());
- }
-
- toggleNavbar() {
- this.setState({ collapsed: !this.state.collapsed });
- }
-
- // This is a real mess. TO CLEAN UP.
- render() {
- const activeStyle = { color: '#FFFFFF' };
-
- const renderMobileNav = () => {
- return
{element.time} | {element.track} | @@ -37,7 +28,6 @@ class ScrobbleTable extends React.Component {
Go-Scrobble is an open source music scrobbling service written in Go and React.
Registration is temporarily disabled. Please try again soon!
- : -Registration is temporarily disabled. Please try again soon!
+ : +- All the settings -
-+ All the settings +