bin/dev-tools/generate-tokens
#!/usr/bin/env perl
# ===================================================================
# File: bin/dev-tools/generate-tokens
# Project: ShinyCMS
# Purpose: Generate tokens for mail_recipient table
#
# Author: Denny de la Haye <2019@denny.me>
# Copyright (c) 2009-2019 Denny de la Haye
#
# ShinyCMS is free software; you can redistribute it and/or modify it
# under the terms of either the GPL 2.0 or the Artistic License 2.0
# ===================================================================
use strict;
use warnings;
# CPAN modules
use DateTime;
use Digest::MD5;
# Load local helper script for fetching schema
use FindBin qw( $Bin );
use lib "$Bin/../lib";
require 'helpers.pl'; ## no critic
my $schema = get_schema();
my @mail_recipients = $schema->resultset( 'MailRecipient' )->all;
foreach my $mr ( @mail_recipients ) {
my $timestamp = DateTime->now->datetime;
my $md5 = Digest::MD5->new;
$md5->add( $mr->email, $timestamp );
my $token = $md5->hexdigest;
$mr->update({ token => $token });
}