Skip to content

Instantly share code, notes, and snippets.

@shamique
shamique / commit-msg
Last active August 18, 2018 16:04
git hook example - commit-msg
#!/bin/sh
# regex pattern for standard message
message_format='^\ABC-[0-9]{4}'
if ! grep -iqE "$message_format" "$1"; then
echo "Error: commit message should follow the pattern of ABC-1234 commit message"
exit 1
fi
@shamique
shamique / pre-commit
Last active August 18, 2018 15:00
git hook - pre-commit
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
DIRTY_SYNTAX="console\|debugger\|<<<<<<<|=======|>>>>>>>"
signUp(email, password) {
return new Promise((resolved, reject) => {
const userPool = new AWSCognito.CognitoUserPool(this._POOL_DATA);
let userAttribute = [];
userAttribute.push(
new AWSCognito.CognitoUserAttribute({ Name: "email", Value: email })
);
userPool.signUp(email, password, userAttribute, null, function(err, result) {
confirmUser(verificationCode, userName) {
return new Promise((resolved, reject) => {
const userPool = new AWSCognito.CognitoUserPool(this._POOL_DATA);
const cognitoUser = new AWSCognito.CognitoUser({
Username: userName,
Pool: userPool
});
cognitoUser.confirmRegistration(verificationCode, true, function(err, result) {
authenticate(email, password) {
return new Promise((resolved, reject) => {
const userPool = new AWSCognito.CognitoUserPool(this._POOL_DATA);
const authDetails = new AWSCognito.AuthenticationDetails({
Username: email,
Password: password
});
const cognitoUser = new AWSCognito.CognitoUser({
<ion-header>
<ion-navbar>
<ion-title>
Ionic cognito app - Sign in
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<form (ngSubmit)="login()" #registerForm="ngForm">
import { Component } from "@angular/core";
import { CognitoServiceProvider } from "../../providers/cognito-service/cognito-service";
import { SignUpPage } from "../../pages/sign-up/sign-up";
@Component({
selector: "page-login",
templateUrl: "login.html"
})
export class LoginPage {
email: string;
<ion-header>
<ion-navbar>
<ion-title>
Ionic cognito app - Sign up
</ion-title>
</ion-navbar>
</ion-header>
<ion-content class="login-content" padding>
<div class="login-box">
import { Component } from "@angular/core";
import { NavController, NavParams } from "ionic-angular";
import { CognitoServiceProvider } from "../../providers/cognito-service/cognito-service";
@Component({
selector: "page-sign-up",
templateUrl: "sign-up.html"
})
export class SignUpPage {
<ion-header>
<ion-navbar>
<ion-title>
Ionic cognito app - Sign up
</ion-title>
</ion-navbar>
</ion-header>
<ion-content class="login-content" padding>
<div class="login-box">