Last change
on this file since 1546 was
870,
checked in by nanardon, 13 years ago
|
- add XML::RPC interface to website
- add XML::RPC clients project
- add tools to allow user to change their password
|
-
Property svn:keywords set to
Id
|
File size:
1.4 KB
|
Line | |
---|
1 | package LATMOS::Accounts::Web::Controller::Rpc; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | $RPC::XML::ENCODING = 'utf-8'; |
---|
5 | |
---|
6 | BEGIN {extends 'Catalyst::Controller'; } |
---|
7 | |
---|
8 | =head1 NAME |
---|
9 | |
---|
10 | LATMOS::Accounts::Web::Controller::Rpc - Catalyst Controller |
---|
11 | |
---|
12 | =head1 DESCRIPTION |
---|
13 | |
---|
14 | Catalyst Controller. |
---|
15 | |
---|
16 | =head1 METHODS |
---|
17 | |
---|
18 | =cut |
---|
19 | |
---|
20 | |
---|
21 | =head2 index |
---|
22 | |
---|
23 | =cut |
---|
24 | |
---|
25 | sub _begin : Private { |
---|
26 | my ($self, $c) = @_; |
---|
27 | } |
---|
28 | |
---|
29 | sub index : Public { |
---|
30 | my ($self, $c) = @_; |
---|
31 | $c->xmlrpc; |
---|
32 | } |
---|
33 | |
---|
34 | sub ech : XMLRPC('ech.ech') { |
---|
35 | my ( $self, $c, @args ) = @_; |
---|
36 | return RPC::XML::fault->new( 400, "No input!" ) unless |
---|
37 | @args; |
---|
38 | return join ' ', @args; |
---|
39 | } |
---|
40 | sub user_change_password : XMLRPC('user.change_password') { |
---|
41 | my ( $self, $c, $username, $oldpasswd, $newpasswd ) = @_; |
---|
42 | return RPC::XML::fault->new( 400, "No input!" ) unless $newpasswd; |
---|
43 | |
---|
44 | $c->authenticate({ |
---|
45 | username => $username, |
---|
46 | password => $oldpasswd, |
---|
47 | }) or return RPC::XML::fault->new( 400, "Cannot authenticate" ); |
---|
48 | |
---|
49 | my $msg = $c->forward('/users/change_password', [ $username, $newpasswd ]); |
---|
50 | if ($msg) { |
---|
51 | return RPC::XML::fault->new( 400, "Error: $msg" ); |
---|
52 | } else { |
---|
53 | return "Password changed"; |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | sub end : Private {} |
---|
59 | |
---|
60 | =head1 AUTHOR |
---|
61 | |
---|
62 | Olivier Thauvin |
---|
63 | |
---|
64 | =head1 LICENSE |
---|
65 | |
---|
66 | This library is free software. You can redistribute it and/or modify |
---|
67 | it under the same terms as Perl itself. |
---|
68 | |
---|
69 | =cut |
---|
70 | |
---|
71 | __PACKAGE__->meta->make_immutable; |
---|
72 | |
---|
73 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.