📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
implemented don't remember me feature
Blue Mouse4d4fb746e465
diff --git a/src/pages/Auth/Signin/Signin.jsx b/src/pages/Auth/Signin/Signin.jsxindex f0640c2ed..d3111fee0 100644--- a/src/pages/Auth/Signin/Signin.jsx+++ b/src/pages/Auth/Signin/Signin.jsx@@ -21,7 +21,7 @@ const Signin = ({ login }) => {const [form, setForm] = useState({email: '',password: '',- keep_signedin: false,+ dontRemember: false,})const [validated, setValidated] = useState(false)const [errors, setErrors] = useState({})@@ -110,10 +110,10 @@ const Signin = ({ login }) => {error={beenSubmitted && errors.password}/><Checkbox- checked={form.keep_signedin}+ checked={form.dontRemember}onChange={handleInput}- name='keep_signedin'- id='keep_signedin'+ name='dontRemember'+ id='dontRemember'className='mt-4'label={t('auth.common.noRemember')}/>diff --git a/src/pages/Auth/Signup/BasicSignup.jsx b/src/pages/Auth/Signup/BasicSignup.jsxindex cdf455b70..2296ac883 100644--- a/src/pages/Auth/Signup/BasicSignup.jsx+++ b/src/pages/Auth/Signup/BasicSignup.jsx@@ -24,7 +24,7 @@ const BasicSignup = () => {password: '',repeat: '',tos: true,- keep_signedin: true,+ dontRemember: false,checkIfLeaked: true,})const [validated, setValidated] = useState(false)diff --git a/src/pages/Auth/Signup/Signup.jsx b/src/pages/Auth/Signup/Signup.jsxindex f595533ff..f045e2682 100644--- a/src/pages/Auth/Signup/Signup.jsx+++ b/src/pages/Auth/Signup/Signup.jsx@@ -26,7 +26,7 @@ const Signup = ({ signup }) => {password: '',repeat: '',tos: false,- keep_signedin: false,+ dontRemember: false,checkIfLeaked: true,})const [validated, setValidated] = useState(false)@@ -188,10 +188,10 @@ const Signup = ({ signup }) => {/></div><Checkbox- checked={form.keep_signedin}+ checked={form.dontRemember}onChange={handleInput}- name='keep_signedin'- id='keep_signedin'+ name='dontRemember'+ id='dontRemember'className='mt-4'label={t('auth.common.noRemember')}/>diff --git a/src/redux/actions/auth/index.js b/src/redux/actions/auth/index.jsindex 74ba37ecd..8543b39ee 100644--- a/src/redux/actions/auth/index.js+++ b/src/redux/actions/auth/index.js@@ -1,5 +1,6 @@import { removeItem } from 'utils/localstorage'-import { TOKEN, LS_VIEW_PREFS_SETTING } from 'redux/constants'+import { removeAccessToken } from 'utils/accessToken'+import { LS_VIEW_PREFS_SETTING } from 'redux/constants'import { types } from './types'export const authActions = {@@ -32,7 +33,7 @@ export const authActions = {},logout() {- removeItem(TOKEN)+ removeAccessToken()removeItem(LS_VIEW_PREFS_SETTING)return {@@ -54,7 +55,7 @@ export const authActions = {},deleteAccountSuccess() {- removeItem('access_token')+ removeAccessToken()removeItem('user_info')return {diff --git a/src/redux/sagas/auth/workers/signin.js b/src/redux/sagas/auth/workers/signin.jsindex bc710a53b..9e5644c6e 100644--- a/src/redux/sagas/auth/workers/signin.js+++ b/src/redux/sagas/auth/workers/signin.js@@ -9,10 +9,11 @@ import { login } from 'api'export default function* singinWorker({ payload: { credentials, callback } }) {try {+ const { dontRemember } = credentialsconst response = yield call(login, credentials)yield put(authActions.loginSuccess(response.user))- yield call(setAccessToken, response.access_token)+ yield call(setAccessToken, response.access_token, dontRemember)yield put(UIActions.loadProjects())callback(true)} catch (error) {diff --git a/src/redux/sagas/auth/workers/signup.js b/src/redux/sagas/auth/workers/signup.jsindex 4ae2a5979..2732fe905 100644--- a/src/redux/sagas/auth/workers/signup.js+++ b/src/redux/sagas/auth/workers/signup.js@@ -9,10 +9,11 @@ import { signup } from 'api'export default function* signupWorder({ payload: { data: rawData, callback, t } }) {try {const { repeat, ...data } = rawData+ const { dontRemember } = dataconst response = yield call(signup, data)yield put(authActions.signupSuccess(response.user))- yield call(setAccessToken, response.access_token)+ yield call(setAccessToken, response.access_token, dontRemember)yield put(UIActions.loadProjects())callback(true)} catch (error) {diff --git a/src/utils/accessToken.js b/src/utils/accessToken.jsindex 3a6156834..6e92ac197 100644--- a/src/utils/accessToken.js+++ b/src/utils/accessToken.js@@ -1,15 +1,27 @@+import _isEmpty from 'lodash/isEmpty'import { TOKEN } from 'redux/constants'import { getItem, setItem, removeItem } from './localstorage'export const getAccessToken = () => {- const accessToken = getItem(TOKEN)+ let accessToken = getItem(TOKEN)++ if (_isEmpty(accessToken)) {+ accessToken = sessionStorage.getItem(TOKEN)+ }+return accessToken}-export const setAccessToken = token => {+export const setAccessToken = (token, temporary = false) => {+ if (temporary) {+ sessionStorage.setItem(TOKEN, token)+ return+ }+setItem(TOKEN, token)}export const removeAccessToken = () => {removeItem(TOKEN)+ sessionStorage.removeItem(TOKEN)}