- Timestamp:
- 12/28/10 18:40:40 (13 years ago)
- Location:
- server/trunk/web/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/lib/Sophie.pm
r124 r209 51 51 xmlrpc => { 52 52 xml_encoding => 'UTF-8', 53 show_errors => 1, 53 54 }, 54 55 -
server/trunk/web/lib/Sophie/Controller/User.pm
r151 r209 4 4 use MIME::Base64; 5 5 use Storable qw/nfreeze thaw/; 6 use YAML; 6 7 7 8 BEGIN {extends 'Catalyst::Controller'; } … … 55 56 } 56 57 58 sub dumpdata : XMLRPC { 59 my ( $self, $c, $dataname ) = @_; 60 61 return $c->stash->{xmlrpc} = YAML::freeze( 62 $c->forward('fetchdata', [ $dataname ]) 63 ); 64 } 65 57 66 sub set_user_data : Private { 58 67 my ( $self, $c, $user, $dataname, $data ) = @_; … … 67 76 }); 68 77 $c->model('Base')->storage->dbh->commit; 78 return $c->stash->{xmlrpc} = 'Updated'; 79 } 80 81 sub setdata : XMLRPC { 82 my ( $self, $c, $dataname, $data ) = @_; 83 84 return $c->forward('set_user_data', [ $c->user->mail, $dataname, $data ]); 85 } 86 87 sub loaddata : XMLRPC { 88 my ( $self, $c, $dataname, $data ) = @_; 89 90 $c->forward('setdata', [ $dataname, YAML::thaw($data) ]); 69 91 } 70 92 … … 88 110 } 89 111 90 sub set data : XMLRPC{91 my ( $self, $c, $dataname, $data) = @_;112 sub set_user_password : Private { 113 my ($self, $c, $user, $clear_password ) = @_; 92 114 93 return $c->forward('set_user_data', [ $c->user->mail, $dataname, $data ]); 115 my @random = (('a'..'z'), ('A'..'Z'), (0 .. 9)); 116 my $salt = join('', map { $random[rand(@random)] } (0..5)); 117 118 my $pass = crypt($clear_password, '$1$' . $salt); 119 if (my $rsuser = $c->model('Base::Users')->find({ 120 mail => $user, 121 } 122 )) { 123 $rsuser->update({ password => $pass }); 124 $c->model('Base')->storage->dbh->commit; 125 return $c->stash->{xmlrpc} = 'Password changed for user ' . $user; 126 } else { 127 $c->error( 'No such user' ); 128 } 129 } 130 131 =head2 user.set_password( PASSWORD ) 132 133 Change the password for the current user to password C<PASSWORD>. 134 135 The change take effect immediately, so user must login again with the new 136 password to continue to use the website. 137 138 The password is stored internally crypted using UNIX MD5 method. 139 140 =cut 141 142 sub set_password : XMLRPC { 143 my ( $self, $c, $clear_password ) = @_; 144 145 $c->forward('set_user_password', [ $c->user->mail, $clear_password ]); 94 146 } 95 147
Note: See TracChangeset
for help on using the changeset viewer.