// from the Starship/CoreID project - app/ldap/controllers/Users.controller.jsconst LDAPController = require('./LDAPController')const LDAP = require('ldapjs')const bcrypt = require('bcrypt')class UsersController extends LDAPController {  static get services() {    return [      ...super.services,      'output',      'ldap_server',      'models',      'configs',      'auth'    ]  }  constructor() {    super()    this.User = this.models.get('auth:User')  }  // Might need to override compare to support special handling for userPassword  // TODO generalize some of the addition logic  // TODO rework some of the registration and validation logic  async add_people(req, res, next) {    const Setting = this.models.get('Setting')    if ( !(await Setting.get('auth.allow_registration')) ) {      return next(new LDAP.InsufficientAccessRightsError('Operation not enabled.'))    }    if ( !req.user.can('ldap:add:users') ) {      return next(new LDAP.InsufficientAccessRightsError())    }    // make sure the add DN is in the auth_dn    const auth_dn = this.ldap_server.auth_dn()    if ( !auth_dn.parentOf(req.dn) ) {      this.output.warn(`Attempted to perform user insertion on invalid DN: ${req.dn.format(this.configs.get('ldap:server.format'))}`)      return next(new LDAP.InsufficientAccessRightsError())    }    // make sure the user object doesn't already exist    const existing_user = await this.get_resource_from_dn(req.dn)    if ( existing_user ) {      return next(new LDAP.EntryAlreadyExistsError())    }    // build the user object from the request attributes    const req_data = req.toObject().attributes    const register_data = {      first_name: req_data.cn ? req_data.cn[0] : '',      last_name: req_data.sn ? req_data.sn[0] : '',      email: req_data.mail ? req_data.mail[0] : '',      username: req_data.uid ? req_data.uid[0].toLowerCase() : '',      password: req_data.userpassword ? req_data.userpassword[0] : '',    }    // TODO add data fields// from the Starship/CoreID project - app/ldap/controllers/Users.controller.jsconst LDAPController = require('./LDAPController')const LDAP = require('ldapjs')const bcrypt = require('bcrypt')class UsersController extends LDAPController {  static get services() {    return [      ...super.services,      'output',      'ldap_server',      'models',      'configs',      'auth'    ]  }  constructor() {    super()    this.User = this.models.get('auth:User')  }  // Might need to override compare to support special handling for userPassword  // TODO generalize some of the addition logic  // TODO rework some of the registration and validation logic  async add_people(req, res, next) {    const Setting = this.models.get('Setting')    if ( !(await Setting.get('auth.allow_registration')) ) {      return next(new LDAP.InsufficientAccessRightsError('Operation not enabled.'))    }    if ( !req.user.can('ldap:add:users') ) {      return next(new LDAP.InsufficientAccessRightsError())    }    // make sure the add DN is in the auth_dn    const auth_dn = this.ldap_server.auth_dn()    if ( !auth_dn.parentOf(req.dn) ) {      this.output.warn(`Attempted to perform user insertion on invalid DN: ${req.dn.format(this.configs.get('ldap:server.format'))}`)      return next(new LDAP.InsufficientAccessRightsError())    }    // make sure the user object doesn't already exist    const existing_user = await this.get_resource_from_dn(req.dn)    if ( existing_user ) {      return next(new LDAP.EntryAlreadyExistsError())    }    // build the user object from the request attributes    const req_data = req.toObject().attributes    const register_data = {      first_name: req_data.cn ? req_data.cn[0] : '',      last_name: req_data.sn ? req_data.sn[0] : '',      email: req_data.mail ? req_data.mail[0] : '',      username: req_data.uid ? req_data.uid[0].toLowerCase() : '',      password: req_data.userpassword ? req_data.userpassword[0] : '',    }    // TODO add data fields// from the Starship/CoreID project - app/ldap/controllers/Users.controller.jsconst LDAPController = require('./LDAPController')const LDAP = require('ldapjs')const bcrypt = require('bcrypt')class UsersController extends LDAPController {  static get services() {    return [      ...super.services,      'output',      'ldap_server',      'models',      'configs',      'auth'    ]  }  constructor() {    super()    this.User = this.models.get('auth:User')  }  // Might need to override compare to support special handling for userPassword  // TODO generalize some of the addition logic  // TODO rework some of the registration and validation logic  async add_people(req, res, next) {    const Setting = this.models.get('Setting')    if ( !(await Setting.get('auth.allow_registration')) ) {      return next(new LDAP.InsufficientAccessRightsError('Operation not enabled.'))    }    if ( !req.user.can('ldap:add:users') ) {      return next(new LDAP.InsufficientAccessRightsError())    }    // make sure the add DN is in the auth_dn    const auth_dn = this.ldap_server.auth_dn()    if ( !auth_dn.parentOf(req.dn) ) {      this.output.warn(`Attempted to perform user insertion on invalid DN: ${req.dn.format(this.configs.get('ldap:server.format'))}`)      return next(new LDAP.InsufficientAccessRightsError())    }    // make sure the user object doesn't already exist    const existing_user = await this.get_resource_from_dn(req.dn)    if ( existing_user ) {      return next(new LDAP.EntryAlreadyExistsError())    }    // build the user object from the request attributes    const req_data = req.toObject().attributes    const register_data = {      first_name: req_data.cn ? req_data.cn[0] : '',      last_name: req_data.sn ? req_data.sn[0] : '',      email: req_data.mail ? req_data.mail[0] : '',      username: req_data.uid ? req_data.uid[0].toLowerCase() : '',      password: req_data.userpassword ? req_data.userpassword[0] : '',    }    // TODO add data fields

Hi, there.

My name is Garrett.

I'm a self-taught software developer and speaker.

Hi, there.

My name is Garrett.

I'm a self-taught software developer and speaker.

about me

Hi! My name is Garrett. Welcome to my little corner of the internet. I'm a self-taught developer and tech-nerd. I create software that I hope makes people's lives better. I created the Flitter web framework, and a couple other fun projects. I love to communicate my work, and help others pursue their projects, which is why I've got a long history of sharing about my passion. I write blog posts, create video tutorials, hold talks, and publish code from my projects in the hope that others will find it useful.

A bit more background: I grew up in the rural mid-west, so I taught myself everything I know. I'm a big fan of learning to code this way. I'm currently studying computer science at the University of Kansas.

about me

Hi! My name is Garrett. Welcome to my little corner of the internet. I'm a self-taught developer and tech-nerd. I create software that I hope makes people's lives better. I created the Flitter web framework, and a couple other fun projects. I love to communicate my work, and help others pursue their projects, which is why I've got a long history of sharing about my passion. I write blog posts, create video tutorials, hold talks, and publish code from my projects in the hope that others will find it useful.

A bit more background: I grew up in the rural mid-west, so I taught myself everything I know. I'm a big fan of learning to code this way. I'm currently studying computer science at the University of Kansas.

get in touch

I'd love to hear from you if you have questions or inquiries related to me or my projects. You can get in touch by text, e-mail, or using this form. I also tweet sometimes, and share thoughts on my blog.

E-Mail: shout@garrettmills.dev
Phone: (913) 730-7124

I'd love to hear from you if you have questions or inquiries related to me or my projects. You can get in touch by text, e-mail, or using this form. I also tweet sometimes, and share thoughts on my blog.

E-Mail: shout@garrettmills.dev
Phone: (913) 730-7124

what I've been up to

Side Project

Side Project

My Technical Notes Site

I'm trying to write down or save all the technical tricks, notes, and fixes I find. That way, it's easier for me to find them again in the future, and maybe they can be of use to others.

You can check them out here.

11/29/2020, 9:13:30 AM

Code Release

Code Release

VuES6 - ES6 Vue.js Components, in Plain JavaScript

I recently released a small utility library for defining Vue components as proper ES6 classes, but in vanilla JavaScript. I like to use this in small projects where I don't want to have to set up vue-cli and compile templates. More info here.

4/22/2020, 11:17:15 PM

Code Release

Code Release

flitter-di@0.1

Flitter-DI is the second-generation dependency-injector used by the Flitter framework. It was pulled from the libflitter project in the hope that it can remain independent from the rest of Flitter and can be used in other projects. More info here.

12/19/2019, 9:19:39 PM

Blog Post

Blog Post

How to Code From Home Like a Boss

With the current need to work from home, I've put together a list of tricks and tools I use to do my work as a software developer remotely, and discuss the challenges. Here's what I use.

2020-07-23T09:15:49.731Z

Code Release

Code Release

Feed Page, RSS, & Atom - Minor Website Updates I recently made some tweaks to my website. I added a dedicated page as a historical archive for these updates.

I also added the ability to subscribe to this feed using RSS, Atom, and JSON thanks to a handy NPM package.

2020-05-09T00:30:33.192Z

Side Project

Side Project

Connect-4 Webtoy

I've built a simple Connect-4 webtoy as a project for EECS 368 at the University of Kansas. You can play with it here.

2020-04-08T14:20:25.849Z

Garrett Mills
Copyright © 2020 Garrett Mills