Skip to content

Instantly share code, notes, and snippets.

View lukichev's full-sized avatar
🏠
Working from home

Andrew Lukichev lukichev

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am lukichev on github.
  • I am lukichev_a (https://keybase.io/lukichev_a) on keybase.
  • I have a public key ASC7nXOujOvkWntVGciBhAUUhy7YfxY-hf_W1wB8TZVOaAo

To claim this, I am signing this object:

@lukichev
lukichev / permission.directive.ts
Created February 19, 2018 06:58
Structural directive for preventing access to some elements by user roles and account types.
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
import { AuthService } from '../../_auth/auth.service';
import { AccountType } from '../../accounts/accounts.service';
import { UserRole } from '../../users/user.model';
@Directive({
selector: '[dcmPermission]',
})
export class PermissionDirective {
import { Injectable, Injector } from '@angular/core';
import {
HttpErrorResponse,
HttpEvent,
HttpHandler,
HttpHeaders,
HttpInterceptor,
HttpRequest,
HttpResponse
} from '@angular/common/http';
@lukichev
lukichev / auth.guard.ts
Last active January 18, 2023 10:15
Role based router permissions
// auth.guard.ts
import {Injectable} from '@angular/core';
import {Router, CanActivate, RouterStateSnapshot, ActivatedRouteSnapshot} from '@angular/router';
import {AuthService} from './auth.service';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private router: Router,
private authService: AuthService) {
}
//
// auth.module.ts
//
import {NgModule} from '@angular/core';
import {AuthenticatedHttpService} from "./http.interceptor";
@NgModule({
providers: [
{provide: Http, useClass: AuthenticatedHttpService}
]
angular
.module('winzzy.games', [
'winzzy.core'
])
.config(configure);
/** @ngInject */
function configure($stateProvider) {
$stateProvider
.state('games', {
class AsideComponent {
/** @ngInject */
constructor($rootScope, Authentication, CONFIG, $timeout) {
this.$rootScope = $rootScope;
this.$timeout = $timeout;
this.Authentication = Authentication;
this.aside_width = CONFIG.aside_menu_width;
this.loading = false;
this.menu = [
class AuthenticationService {
/** @ngInject */
constructor($rootScope, $http, $q, Storage, CONFIG, $timeout, ErrorService, AccountService, PermRoleStore) {
this.$rootScope = $rootScope;
this.$http = $http;
this.$q = $q;
this.Storage = Storage;
this.CONFIG = CONFIG;
this.$timeout = $timeout;
this.ErrorService = ErrorService;
'use strict';
require('dotenv').config({ silent : true });
/**
* Libraries
*/
const
fs = require('fs'),
boolean = require('boolean'),
var debug = require('debug')('jindy:models:message');
var Promise = require('bluebird');
var app = require('../app'),
errors = require('../errors');
module.exports = function(sequelize, DataTypes) {
var Message = sequelize.define('Message', {
text : {