Added device location to home screen.
This commit is contained in:
parent
db5f2731be
commit
fd2659eee5
|
@ -54,6 +54,7 @@ async def login_for_access_token(
|
||||||
db.commit()
|
db.commit()
|
||||||
response.set_cookie(key="device_id", value=str(device.id), max_age=10 * 365 * 24 * 60 * 60)
|
response.set_cookie(key="device_id", value=str(device.id), max_age=10 * 365 * 24 * 60 * 60)
|
||||||
response.set_cookie(key="device", value=device.name, max_age=10 * 365 * 24 * 60 * 60)
|
response.set_cookie(key="device", value=device.name, max_age=10 * 365 * 24 * 60 * 60)
|
||||||
|
response.set_cookie(key="section", value=device.section.name, max_age=10 * 365 * 24 * 60 * 60)
|
||||||
if not allowed:
|
if not allowed:
|
||||||
not_allowed_response = JSONResponse(
|
not_allowed_response = JSONResponse(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
@ -62,6 +63,7 @@ async def login_for_access_token(
|
||||||
)
|
)
|
||||||
not_allowed_response.set_cookie(key="device_id", value=str(device.id), max_age=10 * 365 * 24 * 60 * 60)
|
not_allowed_response.set_cookie(key="device_id", value=str(device.id), max_age=10 * 365 * 24 * 60 * 60)
|
||||||
not_allowed_response.set_cookie(key="device", value=device.name, max_age=10 * 365 * 24 * 60 * 60)
|
not_allowed_response.set_cookie(key="device", value=device.name, max_age=10 * 365 * 24 * 60 * 60)
|
||||||
|
not_allowed_response.set_cookie(key="section", value=device.section.name, max_age=10 * 365 * 24 * 60 * 60)
|
||||||
return not_allowed_response
|
return not_allowed_response
|
||||||
access_token_expires = timedelta(minutes=settings.JWT_TOKEN_EXPIRE_MINUTES)
|
access_token_expires = timedelta(minutes=settings.JWT_TOKEN_EXPIRE_MINUTES)
|
||||||
access_token = create_access_token(
|
access_token = create_access_token(
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
import { environment } from '../../environments/environment';
|
import { environment } from '../../environments/environment';
|
||||||
import { Device } from '../core/device';
|
import { Device } from '../core/device';
|
||||||
|
import { Section } from '../core/section';
|
||||||
import { User } from '../core/user';
|
import { User } from '../core/user';
|
||||||
import { CookieService } from '../shared/cookie.service';
|
import { CookieService } from '../shared/cookie.service';
|
||||||
|
|
||||||
|
@ -23,7 +24,12 @@ export class AuthService {
|
||||||
this.currentUser = this.currentUserSubject.asObservable();
|
this.currentUser = this.currentUserSubject.asObservable();
|
||||||
const deviceId = this.cs.getCookie('device_id');
|
const deviceId = this.cs.getCookie('device_id');
|
||||||
const device = this.cs.getCookie('device');
|
const device = this.cs.getCookie('device');
|
||||||
this.device = new Device({ id: deviceId, name: device });
|
const section = this.cs.getCookie('section');
|
||||||
|
this.device = new Device({
|
||||||
|
id: deviceId,
|
||||||
|
name: device,
|
||||||
|
section: new Section({ name: section }),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static parseJwt(token: string): User {
|
static parseJwt(token: string): User {
|
||||||
|
|
|
@ -270,5 +270,8 @@
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p>Backend: v{{ auth.user?.ver }} / Frontend: v{{ version }} on {{ auth.device.name }}</p>
|
<p>
|
||||||
|
Backend: v{{ auth.user?.ver }} / Frontend: v{{ version }} on {{ auth.device.name }} @
|
||||||
|
{{ auth.device.section.name }}
|
||||||
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
Loading…
Reference in New Issue